如何通过 PublicKeyToken 从 GAC 中批量卸载程序集?

发布于 2024-11-13 10:25:51 字数 222 浏览 12 评论 0原文

是否有办法从 GAC 中卸载具有特定 PublicKeyToken 的所有程序集?

我同意命令行(gacutil.exe 等)或通过 C# 的解决方案。

编辑:

仅供参考,我可以通过 Windows 资源管理器执行此操作,然后转到程序集文件夹并按公钥排序,然后他们选择所有有问题的文件,然后右键单击并说卸载。如果这是唯一的方法,那么请确认,否则可以“自动化”的替代方案会很好。谢谢。

Is there anyway to unload all assemblies from the GAC that have a specific PublicKeyToken?

I am okay with the solution being command-line (gacutil.exe, etc) or via C#.

EDIT:

FYI, I can do this via Windows Explorer and going to the assembly folder and sort by public key and they select all the ones in question and right click and say uninstall. If this is the only way then fine please confirm, otherwise alternatives that could be "automated" would be nice. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

想挽留 2024-11-20 10:25:52

您可以使用 GAC API 编写您自己的工具。 此处是该 API 的托管版本。

You could use the GAC API to code your own tool. Here is a managed version of the API.

虫児飞 2024-11-20 10:25:51

使用命令行和一点 C# 就很简单:

GacUtil /l  

列出 CSV 行上的所有程序集。
在密钥令牌上过滤此内容并将名称提供给 removelist.txt

GacUtil /ul removelist.txt

With the commandline and a little C# it's easy:

GacUtil /l  

Lists all assemblies on CSV lines.
Filter this on the keytoken and feed the names to a removelist.txt for

GacUtil /ul removelist.txt
少跟Wǒ拽 2024-11-20 10:25:51

如果您喜欢 Powershell,您可以使用如下内容:

& 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\gacutil.exe' /L | 
  where { $_ -match '^  ([\w\.]+,.*)
 } |
  foreach {
    if ($matches[1].contains("PublicKeyToken=d7e1d90e83a016b1")) {
      & 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\gacutil.exe' /u $matches[1]
    }
  }

If you like Powershell you could use something like this:

& 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\gacutil.exe' /L | 
  where { $_ -match '^  ([\w\.]+,.*)
 } |
  foreach {
    if ($matches[1].contains("PublicKeyToken=d7e1d90e83a016b1")) {
      & 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\gacutil.exe' /u $matches[1]
    }
  }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文