Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the location of GAC?

Tags:

.net

.net-4.0

gac

I wanted to become more familiar with the .Net Global Assembly Cache. Various sources online say it can be found in Explorer in C:\WINNT\Assembly. But I don't seem to have a WINNT folder under C: on my Windows XP machine. I have "Show Hidden Files and Folders" checked and "Hide Protected Operating System Files" UN-checked.

Using the methods described in How do I detect what .NET Framework versions and service packs are installed? and especially in http://msdn.microsoft.com/en-us/kb/kbarticle.aspx?id=318785 I see that I have .Net 4.0 installed.

How can I reliably find it and why would it be anywhere but where it's supposed to be?

like image 649
user316117 Avatar asked Nov 14 '13 14:11

user316117


People also ask

Where is the GAC location?

Starting with the . NET Framework 4, the default location for the Global Assembly Cache is %windir%\Microsoft.NET\assembly. In earlier versions of the . NET Framework, the default location is %windir%\assembly.

Where is the GAC located in Windows Server 2012?

NET 4.5 on that machine, its GAC is stored in c:\windows\microsoft.net\assembly. You just get to see the actual directory structure. Locating the assembly isn't that difficult, start in the GAC_MSIL directory and you should have no trouble locating your assembly there by its name.

What is GAC and why it is used?

Basically GAC stores assemblies specifically to be shared by many application on computer. The Global Assembly Cache (GAC) is a folder in Windows directory to store the . NET assemblies that are specifically designated to be shared by all applications executed on a system.


2 Answers

As a disclaimer, I'm going to start by saying that you should never directly edit the contents of your GAC.

Moving on to the information...

There are two different GAC's in play in your question, the 2.0 GAC and the 4.0 GAC. When talking about these, they aren't so much referring to the version of the .NET framework, so much as the version of the CLR being used. It just so happens that in 2.0, the CLR is 2, and in 4.0, the CLR is 4. As a frame of reference, the CLR for .Net 3.5 stayed at 2, and hence the GAC for .net 2.0 and .net 3.5 is the same.

But where is it?

The 2.0 GAC is at %WINDIR%\Assembly in explorer. For most newer Windows OS's, %WINDIR% is C:\Windows by default. Under the hood, this is actually a shell extension hiding the real location of the GAC, but for your purposes, you open explorer to C:\Windows\Assembly to view the contents of the 2.0 GAC. The shell extension also adds the benefit of dragging and dropping assemblies into C:\Windows\Assembly in order to add them to the GAC (UAC must be disabled in Win7 and up.)

The 4.0 GAC is at C:\Windows\Microsoft.NET\assembly. You'll find the various types of assemblies divided up into their 32-bit, 64-bit, or MSIL subdirectories under that folder. There is no shell extension for CLR4's gac, so you're looking at the actual place on disk where the assemblies live.

Somewhat off-topic...

The way that I always programmatically detect what versions of the .Net framework are installed is to look at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP ... the sub-folders indicate installed versions.

like image 162
Lynn Crumbling Avatar answered Oct 05 '22 21:10

Lynn Crumbling


in windows xp, its c:\windows\ and its a hidden folder and can find it by manually typing the directory as where you GAC is (WINNT was .NT 4.0 server or workstation, or windows server 2000, or windows 2000) and if upgraded to windows xp or windows server 2003 WINNT I believe would stay intact only in that scenario, that's what you should use the %windir% global system variable

Im on windows 8.1 64 bit and the gac is still in C:\Windows\assembly

but .net is in c:\windows\Microsoft.NET\ is where the CLR and runtime is

Oddly to the other answer above, it seems I disagree that c:\windows\assembly is the "old gac"

here is my dos results

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\WINDOWS\system32>cd..

C:\Windows>cd assembly

C:\Windows\assembly>dir
Volume in drive C is OS
Volume Serial Number is DE26-14AA

Directory of C:\Windows\assembly

11/01/2013  01:15 PM    <DIR>          GAC
11/14/2013  01:10 PM    <DIR>          GAC_32
11/14/2013  01:10 PM    <DIR>          GAC_64
11/14/2013  01:27 PM    <DIR>          GAC_MSIL
11/13/2013  05:36 PM    <DIR>          NativeImages_v2.0.50727_32
11/10/2013  03:22 AM    <DIR>          NativeImages_v2.0.50727_64
11/14/2013  01:33 PM    <DIR>          NativeImages_v4.0.30319_32
11/13/2013  05:36 PM    <DIR>          NativeImages_v4.0.30319_64
11/14/2013  01:33 PM    <DIR>          temp
11/14/2013  01:32 PM    <DIR>          tmp
           0 File(s)              0 bytes
          10 Dir(s)  27,701,415,936 bytes free

C:\Windows\assembly>

the c:\windows\microsoft.net\assembly I do not think is your Active GAC, I think this is where Visual Studio looks for, when compiling for a specific version x64 or 32 etc, the other c:\windows\assembly is the current state of your machine. but im no expert, just what I see

like image 40
MichaelEvanchik Avatar answered Oct 05 '22 22:10

MichaelEvanchik