Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why aren't the .NET Framework 4.0 DLLs added to the GAC?

Tags:

.net

dll

gac

I've noticed something strange about the location of .NET DLLs. I was trying to debug an issue with System.ServiceModel.dll, and I noticed that even though I have .NET 4.0 installed, only the 3.0 version of the ServiceModel DLL is installed in my GAC (I checked by exploring to C:\Windows\assembly). However, if I navigate to "C:\Program Files\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\Profile\Client" the 4.0 version is sitting right there. So why doesn't .NET install the 4.0 versions into the GAC?

And considering it doesn't, how do my 4.0 programs know where to find the 4.0 DLLs? Is the file path I gave above probed automatically? I looked back at my app that uses the 4.0 DLL to confirm that it does NOT copy the DLL locally, so it seems it must be getting it from either the GAC (and now I know the DLL isn't there), or probing in the .NETFramework folder. This has been really confusing me...

Edit: I followed MystereMan's advice and ran "Gacutil.exe /l System.ServiceModel", but it still only shows the 3.0 version. Does that mean the .NET 4 did NOT install the DLLs into the GAC after all?

Edit #2 and resolution: The gacutil.exe in my PATH is an older version that can't see the 4.0 assemblies. By searching my computer, I found the 4.0 version of gacutil.exe here: C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools. Using that, I finally could see listed the 4.0 of System.ServiceModel.dll. Thanks all for the help!

Thanks,

-Robert

like image 695
JoeCool Avatar asked Jun 01 '12 21:06

JoeCool


People also ask

Is GAC part of .NET framework?

GAC is a machine wide a local cache of assemblies maintained by the . NET Framework.

How do I know if assembly is installed in GAC?

If you dont care that the assembly is actually in the GAC, but just loadable on the machine (from the appdomain) you can just use LoadAssembly with the assemblies name (strong, common, full, etc). If the assembly can be loaded by Fusion it will be and then you will know it exists.


1 Answers

.Net 4.0 uses a different GAC, in Windows\Microsoft.Net\assembly.

The files in Reference Assemblies are empty stubs that are only used to filter IntelliSense in Visual Studio for different target frameworks.
If you open them in ILSpy, you'll see that all of the methods are empty.

like image 142
SLaks Avatar answered Oct 14 '22 01:10

SLaks