How are dll's loaded by the CLR?

Posted by priehl on Stack Overflow See other posts from Stack Overflow or by priehl
Published on 2010-06-03T15:02:36Z Indexed on 2010/06/03 15:04 UTC
Read the original article Hit count: 280

Filed under:
|

My assumption was always that the CLR loaded all of the dlls it needed on startup of the app domain. However, I've written an example that makes me question this assumption. I start up my application and check to see how many modules are loaded.

Process[] ObjModulesList;
ProcessModuleCollection ObjModulesOrig;

//Get all modules inside the process
ObjModulesList = Process.GetProcessesByName("MyProcessName");
// Populate the module collection.
ObjModulesOrig = ObjModulesList[0].Modules;

Console.WriteLine(ObjModulesOrig.Count.ToString());

I then repeate the exact same code and my count is different. The additional dll is C:\WINNT\system32\version.dll.

I'm really confused as to why the counts would be different.

Could someone please elaborate on what the clr is doing and how it's loading these thing, and by what logic it's doing so?

© Stack Overflow or respective owner

Related posts about c#

Related posts about clr