我一直在阅读 C# 3.0 的 CLR,并且一直在思考程序集、模块和 header ,但是事情变得复杂了。这就是我的理解,但如果有人能稍微澄清一下就更好了:
模块是包含 IL 代码和元数据表的 csc.exe 的结果。元数据表包含三个不同的表,它们是:
- 定义表,例如“ModuleDef、TypeDef、PropertyDef、MethodDef、EventDef、FieldDef”
- 引用表,例如“TypeRef、ModuleRef、MemberRef 等”。
- list 表**
程序集是包含许多模块以及图像、文档、pdf 等资源的容器。
- 代表可移植可执行文件的 PE 文件是可以是 .EXE 或 .DLL 的文件。这些文件具有 PE32 或 PE32+ header 、CLR header 、元数据、IL 代码。
书上说Assembly是一个由Modules组成的容器,也说Managed Module是
托管模块:
A managed module is a standard 32-bit Microsoft Windows portable executable (PE32) file or a standard 64-bit Windows portable executable (PE32+) file that requires the CLR to execute.
Richter, Jeffrey (2010-02-05). CLR via C# (Kindle Locations 696-697). OReilly Media - A. Kindle Edition.
汇编的定义:
An assembly is a logical grouping of one or more modules or resource files.
Richter, Jeffrey (2010-02-05). CLR via C# (Kindle Locations 766-767). OReilly Media - A. Kindle Edition.
因此,在同一本书的图片中,托管模块似乎实际上是程序集的一部分。
PE32 headers 属于 Assemblies,然而作者也说它也属于 Managed Modules,等等。
这里有什么区别?为什么他使用 Module 和 Assemblies 可互换,即使它们看起来足够独立。
A managed PE file has four main parts: the PE32(+) header, the CLR header, the metadata, and the IL. The PE32(+) header is the standard information that Windows expects. The CLR header is a small block of information that is specific to modules that require the CLR (managed modules).
Richter, Jeffrey (2010-02-05). CLR via C# (Kindle Locations 1628-1629). OReilly Media - A. Kindle Edition.
图片还清楚地表明,模块只有元数据,没有 PE32(+)、CLR header 等。您认为 list 和元数据可以互换使用吗?
您能否也解释一下模块中的 **Manifest 表?
最佳答案
里希特的书很棒,但“真相”在 ECMA CLI standard. 中有定义
根据官方标准定义请查看第5章“术语和定义”。
我认为您只要查看那里的定义,就能最好地理解不同术语之间的共性和差异。
关于c# - CLR 中的模块、程序集、 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10065070/