3 ms·
.NET DLL files are not only MSIL code, they are also native code. If built for the same architecture (x86, x64...) as the importing program, it can be loaded l
by Dwedit 2y ago
.NET DLL files are not only MSIL code, they are also native code. If built for the same architecture (x86, x64...) as the importing program, it can be loaded like any other DLL.
The DLL links to MSCOREE.DLL. When loaded into a process, the DLL can initialize the .NET runtime when necessary. The DLL's entry point is a jump to _CorDllMain within MSCOREE.DLL, which takes care of loading and initializing .NET if it hasn't been done before.
As for how it manages to initialize .NET from within DllMain (you're under DLL loader lock at this point), I don't know. It has to somehow get out of loader lock at some point before it loads a bunch of DLLs.