Where is the location of GAC?

后端 未结 2 1699
隐瞒了意图╮
隐瞒了意图╮ 2021-02-18 15:11

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

2条回答
  •  囚心锁ツ
    2021-02-18 15:39

    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.

提交回复
热议问题