How is the .net referenced assemblies names resolv

2019-08-28 00:14发布

问题:

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