.net 汇编和 DLL 之间的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/674312/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Difference Between Assembly and DLL
提问by Pushkar
What is the difference between Assembly and a DLL? While sending the code to a remote client, should a DLL file be sent or should a Assembly be sent (When direct TCP connection is available between two)?
程序集和 DLL 有什么区别?在将代码发送到远程客户端时,应该发送 DLL 文件还是应该发送程序集(当两者之间有直接 TCP 连接时)?
回答by Jon Skeet
An assembly is .NET's "minimum unit of deployment". Usually an assembly corresponds to a single file, but it doesn't have to - you can have multiple files, with one of them being the master which knows where all the other bits are.
程序集是 .NET 的“最小部署单元”。通常一个程序集对应一个文件,但它不是必须的——你可以有多个文件,其中一个是知道所有其他位在哪里的主文件。
Single-file assemblies are usually DLLs or EXE files. If you've got a normal class library and you just want to send it to the other side, the DLL is what you want. I'd only worry about more complicated scenarios as and when you run into them :)
单文件程序集通常是 DLL 或 EXE 文件。如果您有一个普通的类库,而您只想将其发送到另一端,那么 DLL 就是您想要的。当您遇到更复杂的情况时,我只会担心它们:)
回答by casperOne
Well, a .NET dll is an assembly, but .NET exe's can be assemblies as well, so that means that all .NET dlls are assemblies, but the reverse is not true.
嗯,.NET dll 是一个程序集,但 .NET exe 也可以是程序集,所以这意味着所有 .NET dll 都是程序集,但反之则不然。
You shouldn't be sending actual code to a client. Rather, you should have the type definitions on both sides (client and server) and send serialized instancesbetween the two.
您不应该向客户端发送实际代码。相反,您应该在双方(客户端和服务器)都有类型定义,并在两者之间发送序列化实例。
回答by Atish Dipongkor - MVP
An assembly is basically a file that contains the MSIL Code and Metadata. It is the smallest unit of deployment of .NET applications. An assembly in .NET has 2 extensions (.exe and .dll)
程序集基本上是一个包含 MSIL 代码和元数据的文件。它是 .NET 应用程序的最小部署单元。.NET 中的程序集有 2 个扩展名(.exe 和 .dll)
dll : dynamic link library. So, we can say a dll is an assembly, but an assembly may not always be a dll
dll:动态链接库。所以,我们可以说一个 dll 是一个程序集,但一个程序集可能并不总是一个 dll
In other words, dll is one type of an assembly
换句话说,dll 是一种程序集
回答by mercedes
An assembly is a file that contains the compiled code. There are two kinds of assemblies. When you compile your C# program, you're creating an assembly. Executables (occasionally called "process assemblies") have the EXE file extension. All of the programs in our book are compiled as executables. Those are the assemblies that you can execute; You know, EXE files you can double-click and run. There are also library assemblies, which have the DLL file extension. DLL stand for dynamic link library. They're often referred to as class libraries because they contain classes that you can use in your programs.
程序集是包含已编译代码的文件。有两种装配体。当您编译 C# 程序时,您正在创建一个程序集。可执行文件(有时称为“进程程序集”)具有 EXE 文件扩展名。我们书中的所有程序都编译为可执行文件。这些是您可以执行的程序集;要知道,EXE 文件可以双击运行。还有库程序集,它们具有 DLL 文件扩展名。DLL 代表动态链接库。它们通常被称为类库,因为它们包含您可以在程序中使用的类。
回答by Craig Warren
An assembly is the pre-compiled code which will be passed into a the .net JIT Runtime.
程序集是将被传递到 .net JIT 运行时的预编译代码。
It is a machine independent format for the code which can be run by any .net Command Lanuage Runtime.
它是一种独立于机器的代码格式,可以由任何 .net 命令语言运行时运行。
DLLs and EXEs are the common formats for assemblies.
DLL 和 EXE 是程序集的常用格式。
回答by Jitendra
1:Dll project independent.
1:DLL项目独立。
2:assembly is project specific.
2:装配是特定于项目的。
3:An assembly is a collection of one or more files and one of them DLL or EXE.
3:程序集是一个或多个文件的集合,其中一个是 DLL 或 EXE。
4:DLL contains library code to be used by any program running on Windows. A DLL may contain either structured or object oriented libraries.
4:DLL 包含可供在 Windows 上运行的任何程序使用的库代码。DLL 可能包含结构化或面向对象的库。
5:A DLL file can have a nearly infinite possible entry points.
5:一个DLL文件可以有几乎无限的可能入口点。
6:Assembly present in bin can have either strong/weak Name and assembly in GAC Should have strong name.
6:存在于 bin 中的程序集可以具有强/弱名称,GAC 中的程序集应具有强名称。
回答by Anil Anjana
This question is not seems valid. Both .dll and .exe are assembly. This are just extention of assembly. Both can contains MSIL code but .exe has single entry point i.e. Main function. But .dll can many entry points.
这个问题似乎无效。.dll 和 .exe 都是程序集。这只是装配的延伸。两者都可以包含 MSIL 代码,但 .exe 具有单个入口点,即 Main 函数。但是 .dll 可以有很多入口点。
Assembly is smallest unit of deployment and this can be a dll or exe. This assembly are two types Static and Dynamic. We another type of static assembly i.e known as Satellite assembly which contains resource (images, resource files etc.). You can use strong names for assembly to make it available for globle use by register it in GAC.
程序集是最小的部署单元,可以是 dll 或 exe。这个程序集有静态和动态两种类型。我们另一种类型的静态程序集,即包含资源(图像、资源文件等)的卫星程序集。您可以为程序集使用强名称,通过在 GAC 中注册它以使其可供全局使用。
回答by gujji
.Exe 1.These are outbound file. 2.Only one .exe file exists per application. 3. .Exe cannot be shared with other applications.
.Exe 1.这些是出站文件。2. 每个应用程序只存在一个 .exe 文件。3. .exe 不能与其他应用程序共享。
.dll 1.These are inbund file . 2.Many .dll files may exists in one application. 3. .dll can be shared with other applications.
.dll 1.这些是捆绑文件。2. 一个应用程序中可能存在多个 .dll 文件。3. .dll 可以与其他应用程序共享。
回答by Nick Bedford
Any DLL built from a .NET project is an assembly, as is an executable. Assemblies not only contain the CLI code for running under the Common Language Runtime, they also contain full information about the classes and structure of the code in the assembly.
从 .NET 项目构建的任何 DLL 都是一个程序集,就像一个可执行文件一样。程序集不仅包含用于在公共语言运行时下运行的 CLI 代码,还包含有关程序集中代码的类和结构的完整信息。
Native DLL's are different in that contain barely any meta-information about the code and resources contained within the DLL. A native executable is almost identical to a DLL.
本机 DLL 的不同之处在于它几乎不包含任何关于 DLL 中包含的代码和资源的元信息。本机可执行文件几乎与 DLL 相同。
Assemblies are wonderful because of their modularity and built-in API meta-data.
程序集非常棒,因为它们的模块化和内置的 API 元数据。
回答by user1987058
Assemblies can be organized into a single file where all this information is incorporated into a single dynamic link library (DLL) file or executable (EXE) file, or multiple files where the information is incorporated into separate DLL files main functions of an assembly is to form a boundary for types, references, and security. Another important function of the assembly is to form a unit for deployment.
程序集可以组织到一个文件中,其中所有这些信息都合并到单个动态链接库 (DLL) 文件或可执行 (EXE) 文件中,或者多个文件中,其中信息合并到单独的 DLL 文件中 程序集的主要功能是形成类型、引用和安全的边界。组件的另一个重要功能是形成一个部署单元。
By default, when an assembly is created, it is marked as private.If the assembly must be shared among multiple client assemblies, it is placed in the GAC, a special Windows folder. To convert a private assembly into a shared assembly, you must run a utility program to create encryption keys, and you must sign the assembly with the keys. After signing the assembly, you must use another utility to add the shared assembly into the GAC.
默认情况下,在创建程序集时,它被标记为私有。如果程序集必须在多个客户端程序集之间共享,则将其放置在 GAC(一个特殊的 Windows 文件夹)中。要将私有程序集转换为共享程序集,您必须运行实用程序来创建加密密钥,并且必须使用密钥对程序集进行签名。签署程序集后,您必须使用另一个实用程序将共享程序集添加到 GAC 中。

