3 ms·
How does this differ from the Microsoft solution https://github.com/dotnet/samples/tree/main/core/nativeaot/NativeLibrary https://github.com/dotnet/samples/tree
by pjc50 2y ago
How does this differ from the Microsoft solution https://github.com/dotnet/samples/tree/main/core/nativeaot/NativeLibrary https://github.com/dotnet/samples/tree/main/core/nativeaot/N... ? Is it still MSIL rather than compiled, and if so where does it get the runtime from?
- 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.