How is the .net referenced assemblies names resolved by the clr at runtime?

有些话、适合烂在心里 提交于 2019-12-12 01:26:33

问题


when my .net exe runs, it loads the correct .net assemblies at rumtime. i understand that there is a probing process that happens.

my question is that if i open up the .net exe/dll in ildasm, i only the .extern reference to the mscorlib.dll, not others.

so how does clr gets the information required for doing the probing of the .net referenced assemlies?

i have an example project and the images here.

so in this case, i dont see the .net assembly references anywhere like System, System.Xml.Linq, Questions etc.., but obviously they are loaded by the clr and i do see them in my fusion logviewer

where is the data required for .net assemblies located?

i've noticed some inconsistent behaviour behaviour how the extern assemblies are put the manifest for some core .net dlls and other external .net dlls.

Thanks


回答1:


i got it. Actually i got confused a bit. what ILdasm shows is correct. All statically binded dlls are put in the manifest of the dll.

Why we were not seeing system references is because mscorlib has a piece of ‘System’ namespace; Sysem.dll in GAC has the rest of the classes in that namespace. So System namespace is split in two dlls. Most commonly and basis ones are in mscorelibrary.dll and the rest in system.dll

Actually Visual studio is little bit misleading to show System.dll always as a reference, which is not true always

When I used

     var bvv = new System.Uri("http://www.google.com"); ------ System.Uri class is in System.dll

     Console.WriteLine(bvv.AbsolutePath);--------------------- System.Console class is in mscorlib.dll

i could clearly see the reference to System.dll



来源:https://stackoverflow.com/questions/18637173/how-is-the-net-referenced-assemblies-names-resolved-by-the-clr-at-runtime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!