c# - 什么是托管模块(与程序集相比)?

标签 c# .net

.NET 中的托管模块是什么?它与程序集有何不同? PE 文件(例如 test.dll)是托管模块还是程序集?汇编/托管模块如何对应磁盘上的物理文件?

最佳答案

Managed module一般理解为只包含IL代码,没有直接机器码的模块。

模块位于普通 PE 文件中。

程序集是一组 1 个或多个模块,其中一个指定为“头”(将查找确切的术语 [1])。尽管模块本身并没有多大用处 - 程序集是原子单元。

例如,您可以拥有一个包含 2 个 DLL 和一个 EXE 的多模块程序集。不过,多模块组件非常少见。

Don Box 的书 Esssential .NET, the Richter CLR via C# 很好地涵盖了这个主题。有关完整的详细信息,Serge Lidin .NET 2.0 IL Assembler 一书和 CLI 标准更加完整。

[1] 根据http://www.programmersheaven.com/2/FAQ-DOTNET-DOTNET-Assembly-Explained

An assembly can be a single file or it may consist of the multiple files. In case of multi-file, there is one master module containing the manifest while other assemblies exist as non-manifest modules

回答实际问题:-

What is Managed Module in .NET and how is it different from Assemblies?

它是一个子集——一个 DLL 可以是一个没有子模块的主模块——因此也是一个程序集

Is a PE file (eg. test.dll) a managed module or an assembly?

绝对是一个模块。如果它也有 list 但没有子模块,那么它也是一个程序集

How does assembly/managed module correspond to physical files on disk? Each module is a file. (Tools like ILMerge can merge modules if you're interested)

关于c# - 什么是托管模块(与程序集相比)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1326556/

相关文章:

.net - 如何设置测试SAS数据库的环境?

c# - C# 中的泛型,使用变量类型作为参数

c# - 在实现类 C# 中为接口(interface)成员提供显式实现时允许访问修饰符 nbot

c# - 来自后台 worker 的文本框文本?

c# - 如何在 .net core 2 启动时访问 IConfigurationRoot?

c# - .NET 构造函数和内存管理问题

c# - 注入(inject)需要对象取决于构造函数注入(inject)中的条件

c# - 在 Azure 中部署 MVC 站点时出错

C#/.NET 如何高亮显示DataGridView 中的某些行

c# - 解析Json对象