What is the difference between the IL compiled into the module and the assembly
After compiling the same code into different files, the results are as follows by the Decompile to IL
When compiling into netmodule:
manifest file://Metadata version:v4.0.30319. Assemblyexternmscorlib{. PublicKeyToken= (B7 7A 5C About + theE0 the)//. Z\v.4 .. ver4:0:0:0}.module Mymodule.netmodule//MVID: {db53ec74-cabd-4430-8651-980a2322ad17}. imagebase0x10000000. File Alignment0x00000200. Stackreserve0x00100000. Subsystem0x0003 //Windows_cui. corflags0x00000001 //ilonly//Image base:0x074b0000metainfo Start: ScopeName:MyModule.netmoduleMVID: {db53ec74-cabd-4430-8651-980A2322AD17}
When compiling into assembly:
manifest file://Metadata version:v4.0.30319. Assemblyexternmscorlib{. PublicKeyToken= (B7 7A 5C About + theE0 the)//. Z\v.4 .. ver4:0:0:0}.assembly myassembly{. Custom instancevoid[mscorlib] System.runtime.compilerservices.compilationrelaxationsattribute::.ctor (Int32) = ( on xx , xx xx xx xx xx). Custom Instancevoid[mscorlib] System.runtime.compilerservices.runtimecompatibilityattribute::.ctor () = ( on xx on xx Wu Geneva - $ the A -4E 6F 6E $ + // .... T.. Wrapnonex the $ - About the6F 6E Wu the the6F the the on)//ceptionthrows.. hash algorithm0x00008004. Ver0:0:0:0}.module MyAssembly.exe//MVID: {cdb21366-6ac7-4748-b06a-1b05a6391118}. imagebase0x00400000. File Alignment0x00000200. Stackreserve0x00100000. Subsystem0x0003 //Windows_cui. corflags0x00000001 //ilonly//Image base:0x074b0000metainfo Start: ScopeName:MyAssembly.exeMVID: {CDB21366-6ac7-4748-b06a-1b05a6391118}
When you add an existing module to an assembly:
To add a module mymodule.netmodule to a new assembly:
Compile command: Csc/target:library/addmodule:mymodule.netmodule/out:libraryaddedmodule.dll
To view the results after the decompile:
manifest content://Metadata version:v4.0.30319. Assemblyexternmscorlib{. PublicKeyToken= (B7 7A 5C About + theE0 the)//. Z\v.4 .. ver4:0:0:0}.assembly libraryaddedmodule{. Custom instancevoid[mscorlib] System.runtime.compilerservices.runtimecompatibilityattribute::.ctor () = ( on xx on xx Wu Geneva - $ the A -4E 6F 6E $ + // .... T.. Wrapnonex the $ - About the6F 6E Wu the the6F the the on)//ceptionthrows.. Custom instancevoid[mscorlib] System.runtime.compilerservices.compilationrelaxationsattribute::.ctor (Int32) = ( on xx , xx xx xx xx xx). hash algorithm0x00008004. Ver0:0:0:0}.file mymodule.netmodule. Hash= (6E B4 3E -6D +3 A A the About - +1 b EB theD4//n.>.m!: "Vv....f.E6 5B B9 E8)// . [...class extern Publicprocessdomain.demo{. File mymodule.netmodule.class 0x02000003}.class extern Publicprocessdomain.class1{. File mymodule.netmodule.class 0x02000004}.class extern Publicprocessdomain.classstatic{. File mymodule.netmodule.class 0x02000005}.module LibraryAddedModule.dll//MVID: {FCAFC9D8-E015-472C-AEAA-E6446901A0F7}. imagebase0x10000000. File Alignment0x00000200. Stackreserve0x00100000. Subsystem0x0003 //Windows_cui. corflags0x00000001 //ilonly//Image base:0x087f0000metainfo Start: ScopeName:LibraryAddedModule.dllMVID: {fcafc9d8-E015-472C-AEAA-E6446901A0F7}
As for the difference:
The assembly is more than the module. Assembly section, if the assembly includes a compiled module, there will be a description section of the Reference module. File and. class extern public
An assembly can consist of multiple modules, the role of the module:
The 1 module can start the assembly faster because not all types are in one file and the module is loaded only when needed.
2 When you need multiple languages to create an assembly, one module can be written in VB, another module is written in C #, you can include these two modules in an assembly
C # (dotnet): Different for assembly and module