.NET 单文件程序集说明
在我的书《Pro C# 2008 和 .NET 3.5 Platform》中,在单文件程序集的上下文中,有一行文字让我感到困惑。
在很多情况下,.NET 程序集和二进制文件(*.dll 或 *.exe)之间存在简单的一对一对应关系。因此,如果您是构建 .NET *.dll 时,可以安全地认为二进制文件和程序集是相同的。同样,如果您正在构建可执行桌面应用程序,则 *.exe 可以简单地称为程序集本身
-Pro C# 2008 和 .NET 3.5 平台,Andrew Troelsen
引用的第一句话搞乱了我的想法。我将 .NET 单文件程序集理解为一个或多个相关模块的逻辑分组,这些模块最初作为一个单元进行部署和版本控制。在此程序集中,包含 Windows/CLR 标头、类型元数据、已编译的 CIL 和程序集清单。
在单文件程序集的上下文中,我无法理解“.NET 程序集和二进制文件(*.dll 或 *.exe)之间的一对一对应关系”的含义。
有人可以澄清指定的引用吗?多于?
In my book, "Pro C# 2008 and the .NET 3.5 Platform", there is a line of text that is confusing me, within the context of Single-File assemblies.
In a great number of cases, there is a simple one-to-one correspondence between a .NET assembly and the binary file (*.dll or *.exe). Thus if you are building a .NET *.dll, it is safe to consider that the binary and the assembly are one and the same. Likewise, if you are building an executable desktop application, the *.exe can simply be referred to as the assembly itself
-Pro C# 2008 and the .NET 3.5 platform, Andrew Troelsen
The first sentence of the quote is messing my thinking up. I understand a .NET Single file assembly to be a logical grouping of one or more related modules that are intended to be initially deployed and versioned as a single unit. Within this assembly, contains Windows/CLR headers, type metadata, compiled CIL, and an assembly manifest.
Within the context of single file assemblies, I fail to understand what is meant by a "one-to-one correspondence between a .NET assembly and the binary file (*.dll or *.exe).
Could someone please clarify the quote specified above?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是一个糟糕的评论,作者为了掩饰自己的屁股而设计的。但当他不解释这意味着什么时就没有意义。您关于 Visual Studio 如何工作的思维模型是完整的,一个项目创建一个程序集。
但正如您所猜到的,CLR 没有这个要求。一个组件可以由多个模块构建而成。重要的组成部分是 C# 编译器的 /target:module 选项以及将模块链接到程序集中的 al.exe 工具。这些选项对于 Microsoft 来说非常重要,这就是 mscorlib.dll 等核心程序集的构建方式。机器的灵魂,你不应该走那么远。
It is a sucky comment, designed by the author to cover his ass. But pointless when he doesn't explain what it means. Your mental model about how Visual Studio works is intact, one project creates one assembly.
But as you guessed, the CLR doesn't have this requirement. An assembly can be built-up from multiple modules. The important ingredients are the /target:module option for the C# compiler and the al.exe tool to link the modules into an assembly. These options are very important to Microsoft, that's how core assemblies like mscorlib.dll get built. Soul of the machine stuff, you shouldn't ever have to decent that far.
这只是一个定义问题。包含在单个二进制文件中的任何程序集都可以称为单个文件程序集。
简单地说 - 程序集可以包含在一个或多个二进制文件中。单个二进制文件中的程序集是单个文件程序集。
-前甲板
This is just a matter of defintion. Any assembly that is contained in a single binary can be called a single file assembly.
Simply said - an assembly can be contained in one or more binaries. A assembly that is in a single binary is a single file assembly.
-foredecker
我从未见过一个程序集跨越多个 dll 或 exe 文件。不过,您可以使用 ILmerge 将多个程序集合并为一个二进制文件。通常,您会在每个命名空间看到一个程序集 dll。
I've never seen an assembly span multiple dll or exe files. You can use ILmerge to combine multiple assemblies into a single binary, however. Generally, you will see one assembly dll per namespace.
我认为他指的是“网站项目”将文件背后的单独代码编译成单独的二进制文件,但它们被视为同一“程序集”的一部分。您可以在 windows\Microsoft .net Framework 下的临时位置中看到这些文件
I think what he's referring to is that a "Web site project" compiles individual code behind files into individual binary files, but they are considered part of the same "assembly". You can see these files in the temporary location under windows\Microsoft .net framework