C# 使用 gacutil 安装 .dll

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

Using gacutil to install a .dll

c#dllgacutil

提问by scapegoat17

I am trying to install a .dll refrence to use it in my code, but i am having issues using the gacutil. Would anyone be able to help me with the format of this?

我正在尝试安装 .dll 引用以在我的代码中使用它,但是我在使用 gacutil 时遇到了问题。有人能帮我解决这个格式吗?

I have tried using http://msdn.microsoft.com/en-us/library/ex0ss12c.aspxBut i must still be doing something wrong...

我试过使用http://msdn.microsoft.com/en-us/library/ex0ss12c.aspx但我一定还是做错了什么......

the .dll that i am trying to install is Office.dll

我要安装的 .dll 是 Office.dll

Here is what i have tried:

这是我尝试过的:

gacutil /i Office.dll "C:\File\path\Office.dll"

It comes up with an error saying:

它提出了一个错误说:

Unknown option: C:\File\path\Office.dll

Would anyone have any ideas to help me with this?

有没有人有任何想法可以帮助我解决这个问题?

采纳答案by Royi Namir

You don't need the second param

你不需要第二个参数

just use :

只需使用:

gacutil /i "C:\File\path\Office.dll"

gacutil /i "C:\File\path\Office.dll"

回答by Alex

Try gacutil /i "C:\File\path\Office.dll". Also please note that assembly must be strongly named to be installed correctly in GAC.

试试gacutil /i "C:\File\path\Office.dll"。另请注意,必须对程序集进行强命名才能在 GAC 中正确安装。

回答by Kurubaran

You can easily add dll to GAC using Publishclass. Add reference to System.EnterpriseServices

您可以使用Publish类轻松地将 dll 添加到 GAC 。添加参考System.EnterpriseServices

System.EnterpriseServices.Internal.Publish publish = new System.EnterpriseServices.Internal.Publish();
publish.GacInstall("dll path");