CLR在加载程序集的时候会查看程序集清单,程序集清单包含哪些内容呢?可执行文件和程序集有什么区别/
程序集清单
□ 查看程序集清单
→清空F盘as文件夹中的所有内容→创建MainClass.cs文件→把MainClass.cs编译成程序集→反编译MyDll.dll,在1.txt文件中呈现
→打开1.txt文件ildasm /out:1.txt MyDll.dll
1.txt
// Metadata version: v4.0.30319.assembly extern mscorlib{.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z/V.4...ver 4:0:0:0}.assembly MyDll{.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ).custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows..hash algorithm 0x00008004.ver 0:0:0:0}.module MyDll.dll// MVID: {7BE59AA1-0AE6-426E-B77D-5B85AB4B163F}.imagebase 0x10000000.file alignment 0x00000200.stackreserve 0x00100000.subsystem 0x0003 // WINDOWS_CUI.corflags 0x00000001 // ILONLY// Image base: 0x00A00000// *********** 反汇编完成 ***********************// 警告: 创建了 Win32 资源文件 1.res
○ .assembly extern mscorlib,不管MainClass.cs中有没有代码,一定会引用mscorlib程序集○ .assembly MyDll语句块中的内容就是程序集清单,manifest○ .hash algorithm 0x00008004和.ver 0:0:0:0是程序集清单中2个重要的方面
□ 查看module清单
→把MainClass.cs编译成module
csc /t:module /out:MyModule.netmodule MainClass.cs
→反编译MyModule,在2.txt文件中打开
<PRe style="font-size: 11px; font-family: consolas,'Courier New',courier,monospace; width: 100%; margin: 0em; b
新闻热点
疑难解答