什么是.NET程序集?我在网上浏览了一下,我不明白这个定义。


当前回答

维基百科说:

In the Microsoft .NET framework, an assembly is a partially compiled code library for use in deployment, versioning and security. There are two types: process assemblies (EXE) and library assemblies (DLL). A process assembly represents a process which will use classes defined in library assemblies. .NET assemblies contain code in CIL, which is usually generated from a CLI language, and then compiled into machine language at runtime by the CLR just-in-time compiler. An assembly can consist of one or more files. Code files are called modules. An assembly can contain more than one code module and since it is possible to use different languages to create code modules it is technically possible to use several different languages to create an assembly. Visual Studio however does not support using different languages in one assembly.

如果你真的浏览过,澄清你不理解的地方会有帮助

其他回答

看到这个:

在Microsoft .NET框架中,程序集是用于部署、版本控制和安全的部分编译代码库

MSDN给出了一个很好的解释:

Assemblies are the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the common language runtime with the information it needs to be aware of type implementations. To the runtime, a type does not exist outside the context of an assembly.

程序集是.net应用程序的最小部署单元。 它可以是一个dll或exe。 主要有两种类型:

私人组装: dll或exe只是一个应用程序的唯一属性。它通常存储在应用程序根文件夹中 公共/共享组装: 它是一个可以同时被多个应用程序使用的dll。共享程序集存储在GAC中,即全局程序集缓存。

听起来困难吗?Naa…… GAC就是C:\Windows\Assembly文件夹,在这里您可以找到安装在PC上的所有软件的公共程序集/dll。

还有第三种也是最不为人知的装配类型:卫星装配。 附属程序集只包含静态对象,如图像和应用程序所需的其他非可执行文件。

在Microsoft.Net中,程序集是代码版本安全、部署和可重用性的最小单元。

它包含:

- Assembly Identity
- Manifest
- Metadata
- MSIL Code
- Security Information
- Assembly Header

程序集是构成逻辑功能单元的类型和资源的集合。.NET Framework中的所有类型都必须存在于程序集中;公共语言运行库不支持程序集之外的类型。每次使用Visual Basic . net创建Microsoft Windows®应用程序、Windows服务、类库或其他应用程序时,您都在构建单个程序集。每个程序集都存储为.exe或.dll文件。

来源:https://msdn.microsoft.com/en-us/library/ms973231.aspx#assenamesp_topic4

对于像我这样有Java背景的人来说,希望下面的图表能够阐明概念

程序集就像jar文件(包含多个.class文件)。您的代码可以引用现有的程序集,或者您的代码本身可以作为程序集发布,以供其他代码引用和使用(您可以将其视为Java中的jar文件,可以添加到项目依赖项中)。

最后,程序集是可以在任何安装了CLR的操作系统上运行的编译代码。这就相当于说.class文件或捆绑的jar可以在任何安装了JVM的机器上运行。