C# 如何在没有 GacUtil 的情况下在 GAC 中注册程序集?

发布于 2024-09-04 11:23:09 字数 85 浏览 2 评论 0原文

我需要使用批处理文件在 GAC 中注册程序集。有没有办法找到 GacUtil.exe 的安装位置,或者有没有办法在没有 GacUtil 的情况下注册程序集?

I need to register an assembly in the GAC using batch file. Is there a way to find the installation location of GacUtil.exe or is there a way to register the assembly without GacUtil?

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

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

发布评论

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

评论(4

喜你已久 2024-09-11 11:23:09

最好的选择是使用包含 的 powershell 脚本Publish.GacInstall,例如这个

Your bestbet is to use a powershell script that wraps Publish.GacInstall, such as this one????

听闻余生 2024-09-11 11:23:09

GacUtil 不随框架安装而安装,仅随 SDK 安装而安装 - 因此您无法保证它会出现在您要安装的机器上。

这在您的批处理文件中不起作用,但如果您自己开发了应用程序,则可以使用下面描述的 GacInstall 方法:
http://msdn.microsoft.com/en -us/library/system.enterpriseservices.internal.publish.gacinstall.aspx

或者,我建议生成一个 msi 文件来部署应用程序。教程在这里:
http://www.dreamincode.net/forums/topic/58021-deploying-ac%23-application-visual-studio-setup-project/

包含 GacUtil.exe 副本是一个不可取的解决方案在您的发行版中,因为它采用不同的许可证,并且您可能无权重新分发它

GacUtil is not installed with a framework install only with an SDK install - so you couldn't guarantee it would be on the box you're installing on.

This won't work within your batch file but if you have developed the application yourself you can use the GacInstall method described below:
http://msdn.microsoft.com/en-us/library/system.enterpriseservices.internal.publish.gacinstall.aspx

Alternatively I'd recommend producing an msi file to deploy the application. Tutorial here:
http://www.dreamincode.net/forums/topic/58021-deploying-a-c%23-application-visual-studio-setup-project/

It would be an inadvisable solution to include a copy of GacUtil.exe in your distribution because it comes under a different licence and you probably aren't licenced to redistribute it

甲如呢乙后呢 2024-09-11 11:23:09

您可以通过执行以下操作将 dll 安装到 GAC(全局程序集缓存)中。

[Reflection.Assembly]::LoadWithPartialName("System.EnterpriseServices") | Out-Null 
[System.EnterpriseServices.Internal.Publish] $publish = new-object System.EnterpriseServices.Internal.Publish
$publish.GacInstall(<<FullFilePathToTheDll>>)

这与本机 PowerShell 关系不大,但与实例化和使用 PowerShell 中的 .NET 库有关。

执行 iisreset

来源

You may install a dll into the GAC (global assembly cache) by doing the following

[Reflection.Assembly]::LoadWithPartialName("System.EnterpriseServices") | Out-Null 
[System.EnterpriseServices.Internal.Publish] $publish = new-object System.EnterpriseServices.Internal.Publish
$publish.GacInstall(<<FullFilePathToTheDll>>)

This has to do very little with native PowerShell but rather with instantiating and using .NET libraries from PowerShell

Do a iisreset.

Source

萌酱 2024-09-11 11:23:09

我使用 InnoSetup 并创建了一个安装,包括我的程序集。

重要的一行如下:

Source: "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"; DestDir: "{app}"; StrongAssemblyName: "WinSCPnet, Version=1.3.7.7333, Culture=neutral, PublicKeyToken=2271ec4a3c56d0bf, ProcessorArchitecture=MSIL"; Flags: ignoreversion gacinstall uninsnosharedfileprompt

I used InnoSetup and created an installation including my assembly.

The important line is like below:

Source: "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"; DestDir: "{app}"; StrongAssemblyName: "WinSCPnet, Version=1.3.7.7333, Culture=neutral, PublicKeyToken=2271ec4a3c56d0bf, ProcessorArchitecture=MSIL"; Flags: ignoreversion gacinstall uninsnosharedfileprompt
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文