C# 如何在没有 GacUtil 的情况下在 GAC 中注册程序集?
我需要使用批处理文件在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
最好的选择是使用包含 的 powershell 脚本Publish.GacInstall,例如这个
Your bestbet is to use a powershell script that wraps Publish.GacInstall, such as this one????
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
您可以通过执行以下操作将 dll 安装到 GAC(全局程序集缓存)中。
这与本机 PowerShell 关系不大,但与实例化和使用 PowerShell 中的 .NET 库有关。
执行
iisreset
。来源
You may install a dll into the GAC (global assembly cache) by doing the following
This has to do very little with native PowerShell but rather with instantiating and using .NET libraries from PowerShell
Do a
iisreset
.Source
我使用 InnoSetup 并创建了一个安装,包括我的程序集。
重要的一行如下:
I used InnoSetup and created an installation including my assembly.
The important line is like below: