究竟什么是 C# 或 .NET 中的程序集? [英] What exactly is an Assembly in C# or .NET?

查看:34
本文介绍了究竟什么是 C# 或 .NET 中的程序集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您能否解释一下 C# 或 .NET 中的程序集是什么?

Could you please explain what is an Assembly in C# or .NET?

  1. 它从哪里开始,到哪里结束?
  2. 关于程序集,我应该了解哪些重要信息?

推荐答案

程序集是代码的编译输出,通常是 DLL,但您的 EXE 也是程序集.它是任何 .NET 项目的最小部署单元.

An assembly is the compiled output of your code, typically a DLL, but your EXE is also an assembly. It's the smallest unit of deployment for any .NET project.

程序集通常包含 MSIL(Microsoft 中间语言)中的 .NET 代码,这些代码将在第一次在给定机器上执行时编译为本机代码(JITted" - 由即时编译器编译).编译后的代码也将存储在程序集中并在后续调用中重复使用.

The assembly typically contains .NET code in MSIL (Microsoft Intermediate language) that will be compiled to native code ("JITted" - compiled by the Just-In-Time compiler) the first time it is executed on a given machine. That compiled code will also be stored in the assembly and reused on subsequent calls.

程序集还可以包含图标、位图、字符串表等资源.此外,程序集还在程序集清单中包含元数据 - 诸如版本号、强名称、区域性、引用的程序集等信息.

The assembly can also contain resources like icons, bitmaps, string tables and so on. Furthermore, the assembly also contains metadata in the assembly manifest - information like version number, strong name, culture, referenced assemblies and so forth.

在 99% 的情况下,一个程序集等于磁盘上的一个物理文件 - 多文件程序集(一个程序集,分布在多个文件中)的情况似乎是一个相当奇怪的边缘情况在我 5 年多的 .NET 开发中,到目前为止我从未遇到过.

In 99% of your cases, one assembly equals a physical file on disk - the case of a multi-file assembly (one assembly, distributed across more than a single file) appears to be a rather odd-ball edge case which I've never encountered so far in my 5+ years of .NET development.

在多文件程序集中,DLL 或 EXE 中仍然只有一个程序集清单,多个网络模块文件中仍然只有 MSIL 代码.

In a multifile assembly there would still be only one assembly manifest in a DLL or EXE and the MSIL code in multiple netmodule files.

这篇关于究竟什么是 C# 或 .NET 中的程序集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆