.net GAC 的位置在哪里?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19980650/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Where is the location of GAC?
提问by user316117
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 WINNTfolder under C:on my Windows XP machine. I have "Show Hidden Files and Folders" checked and "Hide Protected Operating System Files" UN-checked.
我想更加熟悉 .Net 全局程序集缓存。网上的各种消息来源说它可以在C:\WINNT\Assembly. 但是我的 Windows XP 机器上似乎没有WINNT文件夹C:。我已选中“显示隐藏的文件和文件夹”并选中“隐藏受保护的操作系统文件”。
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=318785I see that I have .Net 4.0 installed.
使用如何检测安装的 .NET Framework 版本和服务包中描述的方法?尤其是在http://msdn.microsoft.com/en-us/kb/kbarticle.aspx?id=318785 中,我看到我安装了 .Net 4.0。
How can I reliably find it and why would it be anywhere but where it's supposed to be?
我怎样才能可靠地找到它,为什么它会在任何地方而不是它应该在的地方?
回答by Lynn Crumbling
As a disclaimer, I'm going to start by saying that you should never directly edit the contents of your GAC.
作为免责声明,我首先要说的是,永远不要直接编辑 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.
您的问题中有两个不同的 GAC,即 2.0 GAC 和 4.0 GAC。在谈论这些时,它们并不是指 .NET 框架的版本,而是指正在使用的 CLR 的版本。碰巧的是,在 2.0 中,CLR 为 2,而在 4.0 中,CLR 为 4。作为参考框架,.Net 3.5 的 CLR 保持在 2,因此 .net 2.0 和 .net 3.5 的 GAC是一样的。
But where is it?
但它在哪里?
The 2.0 GAC is at %WINDIR%\Assemblyin explorer. For most newer Windows OS's, %WINDIR%is C:\Windowsby 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\Assemblyto view the contents of the 2.0 GAC. The shell extension also adds the benefit of dragging and dropping assemblies into C:\Windows\Assemblyin order to add them to the GAC (UAC must be disabled in Win7 and up.)
2.0 GAC%WINDIR%\Assembly位于资源管理器中。对于大多数较新的Windows操作系统的,%WINDIR%就是C:\Windows默认。在幕后,这实际上是隐藏 GAC 真实位置的外壳扩展,但出于您的目的,您可以打开资源管理器C:\Windows\Assembly以查看 2.0 GAC 的内容。shell 扩展还增加了将程序集拖放C:\Windows\Assembly到 GAC 中的好处(必须在 Win7 及更高版本中禁用 UAC。)
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.
4.0 GAC 位于C:\Windows\Microsoft.NET\assembly. 您会发现各种类型的程序集在该文件夹下分为 32 位、64 位或 MSIL 子目录。CLR4 的 gac 没有外壳扩展,因此您正在查看程序集所在磁盘上的实际位置。
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.
我总是以编程方式检测安装了哪些版本的 .Net 框架的方法是查看HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP......子文件夹指示已安装的版本。
回答by MichaelEvanchik
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
在 windows xp 中,它的 c:\windows\ 和它的一个隐藏文件夹,可以通过手动键入 GAC 所在的目录来找到它(WINNT 是 .NT 4.0 服务器或工作站,或 windows server 2000,或 windows 2000),如果升级到 windows xp 或 windows server 2003 WINNT 我相信只有在那种情况下才会保持完整,这就是你应该使用 %windir% 全局系统变量
Im on windows 8.1 64 bit and the gac is still in C:\Windows\assembly
我在 Windows 8.1 64 位上,gac 仍在 C:\Windows\assembly
but .net is in c:\windows\Microsoft.NET\ is where the CLR and runtime is
但是 .net 在 c:\windows\Microsoft.NET\ 是 CLR 和运行时所在的位置
Oddly to the other answer above, it seems I disagree that c:\windows\assembly is the "old gac"
奇怪的是上面的另一个答案,我似乎不同意 c:\windows\assembly 是“旧 gac”
here is my dos results
这是我的 dos 结果
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
c:\windows\microsoft.net\assembly 我不认为是你的 Active GAC,我认为这是 Visual Studio 寻找的地方,在编译特定版本 x64 或 32 等时,另一个 c:\windows\assembly 是您机器的当前状态。但我不是专家,只是我所看到的

