.net Gacutil.exe 成功添加程序集,但无法在资源管理器中查看程序集。为什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3054304/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 14:25:04  来源:igfitidea点击:

Gacutil.exe successfully adds assembly, but assembly not viewable in explorer. Why?

.netwindowsassembliesgacgacutil

提问by Ben McCormack

I'm running GacUtil.exe from within Visual Studio Command Prompt 2010 to register a dll (CatalogPromotion.dll) to the GAC. After running the utility, it says Assembly Successfully added to the cache, and running gacutil /l CatalogPromotionDllshows that the GAC contains the assembly, but I can't see the assembly when I navigate to C:\WINDOWS\assembly from Windows Explorer. Why can't I see the assembly in WINDOWS\assembly from Windows Explorer but I can see it using gacutil.exe?

我正在 Visual Studio 命令提示符 2010 中运行 GacUtil.exe,以将 dll (CatalogPromotion.dll) 注册到 GAC。运行该实用程序后,它显示Assembly Successfully added to the cache,并且运行gacutil /l CatalogPromotionDll显示 GAC 包含程序集,但是当我从 Windows 资源管理器导航到 C:\WINDOWS\assembly 时看不到该程序集。 为什么我在 Windows 资源管理器中看不到 WINDOWS\assembly 中的程序集,但我可以使用 gacutil.exe 看到它?



Background: Here's what I typed into the command prompt for VS Tools:

背景:这是我在 VS Tools 的命令提示符中输入的内容:

    C:\_Dev Projects\VS Projects\bmccormack\CatalogPromotion\CatalogPromotionDll\bin
    \Debug>gacutil /i CatalogPromotionDll.dll
    Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.1
    Copyright (c) Microsoft Corporation.  All rights reserved.

    Assembly successfully added to the cache

    C:\_Dev Projects\VS Projects\bmccormack\CatalogPromotion\CatalogPromotionDll\bin
    \Debug>gacutil /l CatalogPromotionDll
    Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.1
    Copyright (c) Microsoft Corporation.  All rights reserved.

    The Global Assembly Cache contains the following assemblies:
      CatalogPromotionDll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9188a175
    f199de4a, processorArchitecture=MSIL

    Number of items = 1

However, the assembly doesn't show up in C:\WINDOWS\assembly.

但是,程序集不会出现在 C:\WINDOWS\assembly 中。

回答by Hans Passant

That's because you use the .NET 4.0 version of gacutil.exe. It stores the assembly in a differentGAC, the one in c:\windows\microsoft.net\assembly. Where all .NET 4.0 assemblies are stored. There is no shell extension handler for that one, the folders are visible as-is. You can have a look-see with Windows Explorer, .you'll see the internal structure of the GAC folders. You shouldn't have any trouble finding your assembly back, the GAC isn't particularly complicated.

那是因为您使用了 gacutil.exe 的 .NET 4.0 版本。它将程序集存储在不同的GAC 中,即 c:\windows\microsoft.net\assembly 中的那个。所有 .NET 4.0 程序集的存储位置。该文件夹没有外壳扩展处理程序,文件夹按原样可见。您可以使用 Windows 资源管理器查看,您将看到 GAC 文件夹的内部结构。找回程序集应该不会有任何问题,GAC 并不是特别复杂。

If the assembly is intended to be used by an app that targets an earlier version of .NET then you should use the .NET 2.0 version of gacutil.exe, stored in C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin

如果程序集旨在由面向 .NET 早期版本的应用程序使用,那么您应该使用存储在 C:\Program Files\Microsoft SDKs\Windows\v6.0A\ 中的 gacutil.exe 的 .NET 2.0 版本垃圾桶

回答by gravidThoughts

This is because the assembly you are installing into the GAC was compiled targeting the 4.0 runtime. 4.0 GAC assemblies are stored in a different location c:\windows\microsoft.net\assembly.

这是因为您安装到 GAC 中的程序集是针对 4.0 运行时编译的。4.0 GAC 程序集存储在不同的位置 c:\windows\microsoft.net\assembly。

The accepted answer is incorrect. Using the .NET 4.0 gacutil to install an assembly compiled targeting 3.5 or earlier runtime works just fine, and will place the assembly in the directory the OP was expecting, c:\windows\assembly.

接受的答案是不正确的。使用 .NET 4.0 gacutil 安装针对 3.5 或更早版本的运行时编译的程序集可以正常工作,并且会将程序集放置在 OP 期望的目录 c:\windows\assembly 中。

回答by bijitm

The path is -> C:\Windows\Microsoft.NET\assembly\GAC_MSIL where all the assemblies are stored for .net 4.0 version

路径是 -> C:\Windows\Microsoft.NET\assembly\GAC_MSIL,其中存储了 .net 4.0 版本的所有程序集