[英]C# how to register assembly in the GAC without GacUtil?
I need to register an assembly in the GAC using batch file.我需要使用批处理文件在 GAC 中注册一个程序集。 Is there a way to find the installation location of
GacUtil.exe
or is there a way to register the assembly without GacUtil?有没有办法找到
GacUtil.exe
的安装位置,或者有没有办法在没有 GacUtil 的情况下注册程序集?
你最好的选择是使用一个包装Publish.GacInstall的 powershell 脚本,比如这个🕗
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. GacUtil 不与框架安装一起安装,仅与 SDK 安装一起安装 - 因此您不能保证它会在您正在安装的机器上。
This won't work within your batch file but if you have developed the application yourself you can use the GacInstall method described below:这在您的批处理文件中不起作用,但如果您自己开发了应用程序,则可以使用下面描述的 GacInstall 方法:
http://msdn.microsoft.com/en-us/library/system.enterpriseservices.internal.publish.gacinstall.aspx 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.或者,我建议生成一个 msi 文件来部署应用程序。 Tutorial here:
教程在这里:
http://www.dreamincode.net/forums/topic/58021-deploying-ac%23-application-visual-studio-setup-project/ http://www.dreamincode.net/forums/topic/58021-deploying-ac%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在您的发行版中包含 GacUtil.exe 的副本将是一个不可取的解决方案,因为它具有不同的许可证,并且您可能没有获得重新分发它的许可
You may install a dll into the GAC (global assembly cache) by doing the following您可以通过执行以下操作将 dll 安装到 GAC(全局程序集缓存)中
[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这与本机 PowerShell 无关,而是与从 PowerShell 实例化和使用 .NET 库有关
Do a iisreset
.做一个
iisreset
。
I used InnoSetup and created an installation including my assembly.我使用了 InnoSetup 并创建了一个包含我的程序集的安装。
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.