I am trying to get something clarified.
When a .NET console application is run, does mscorlib.dll/mscoree.dll get loaded in the process's virtual address space?
mscorlib.dll and mscoree.dll (CLR) are not managed dlls. Is that correct?
Also, what is a good resource to understand more about how a .NET program is executed?
Yes. You'll always get mscoree.dll loaded, that's the bootstrapper for the default CLR host. It is an unmanaged DLL. Every .NET assembly contains a wee bit of native code, just a jump into that DLL. It does however get loaded by recent Windows versions directly, the OS loader has .NET awareness built-in. You can see it in the Debug + Modules window when you turn on the unmanaged debugging option, Project + Properties, Debug tab. You'll then also see mscorjit.dll, mscorwks.dll and msvcr80.dll, three other chunks of native code that are required to run managed code. Respectively the just-in-time compiler, the CLR and the C-runtime support library. They have different DLL names in .NET 4.
Technically it is possible to not get mscorlib.dll loaded, the compiler has the /nostdlib option to avoid a reference to that assembly. Practically that only works if you provide a substitute, that's how Silverlight gets compiled for example. It is otherwise a mixed-mode assembly with some native code but mostly managed code. There's a separate version of it for the 64-bit framework because of that. You'll also see mscorlib.ni.dll with unmanaged debugging enabled, that's the ngen-ed version of the assembly.
I would recommend to read the Jefrey Richter's book CLR via C#. It provides very clear explanation what is going on under the hood :)
Also yoг may find this question helpful: Why is an assembly .exe file?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With