如何在 GAC 中注册 .NET DLL 文件?
我制作了一个 .NET .DLL
文件,我想在 GAC 中注册该文件。
我在 Windows Server 2003 中使用了此命令 命令提示符:
C:\"Path of dll"\>gacutil /i dllname.dll
'gacutil' is not recognized as an internal or external command,
operable program or batch file.
它表示路径不正确。
我需要在 .NET cmd 提示符中使用它吗?如果是这样,我将无法找到 .NET cmd 提示符。
I have made a .NET .DLL
file, which I want to register in the GAC.
I have used this command in Windows Server 2003 Command Prompt:
C:\"Path of dll"\>gacutil /i dllname.dll
'gacutil' is not recognized as an internal or external command,
operable program or batch file.
It says the path is not correct.
Do I need to use this in a .NET cmd prompt? If it is that, I am not able to locate the .NET cmd prompt.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(13)
您可以使用
gacutil
来完成此操作工具。最简单的形式是:您可以在开始菜单中的程序 -> 下找到 Visual Studio 命令提示符。 Visual Studio -> Visual Studio 工具。
You can do that using the
gacutil
tool. In its simplest form:You find the Visual Studio Command Prompt in the start menu under Programs -> Visual Studio -> Visual Studio Tools.
您需要:
现在,每次构建项目时,它都会将安装在 GAC 上。
You'll need:
Now, everytime you build your project, it'll be installed on GAC.
只需使用 Windows 资源管理器将 DLL 文件拖放到文件夹
C:\Windows\ assembly
中即可。注意事项:
来源:如何:将程序集安装到全局程序集中缓存
Just drag and drop the DLL file into folder
C:\Windows\assembly
using Windows Explorer.Caveat:
Source: How to: Install an assembly into the global assembly cache
这些响应并没有告诉您 gacutil 驻留在
C:\WINDOWS\Microsoft.NET\Framework\v1.1*
顺便一提。
我的 v2.0 文件夹中没有它。但我尝试拖动 &按照之前的建议,将 DLL 放入 C:\WINDOWS\Assembly 文件夹中,这样更容易并且有效,只要它是 .NET 库即可。我还尝试了 COM 库,但失败并出现错误,表明它需要程序集清单。我知道这不是这里的问题,但我想我会提到,万一有人发现他们无法添加它,这可能就是原因。
-汤姆
These responses don't tell you that gacutil resides in
C:\WINDOWS\Microsoft.NET\Framework\v1.1*
by the way.
I didn't have it in my v2.0 folder. But I tried dragging & dropping the DLL into the C:\WINDOWS\Assembly folder as was suggested here earlier and that was easier and does work, as long as it's a .NET library. I also tried a COM library and this failed with an error that it was expecting an assembly manifest. I know that wasn't the question here, but thought I'd mention that in case someone finds out they can't add it, that that might be why.
-Tom
来自维基百科:
可以使用以下命令在 GAC 中检查共享程序集的可用性:
可以使用以下命令在 GAC 中注册共享程序集:
或者通过删除程序集文件使用 GUI 进入以下位置:
如果使用
/?
标志,将简要描述此实用程序的其他选项,即:From Wikipedia:
One can check the availability of a shared assembly in GAC by using the command:
One can register a shared assembly in the GAC by using the command:
Or by dropping an assembly file into the following location using the GUI:
Other options for this utility will be briefly described if you use the
/?
flag, that is:如果您害怕命令提示符,请尝试 GACView。
您没有在 DOS 中正确设置 PATH。您需要将路径指向 gacutil 所在位置才能在 DOS 中使用它。
Try GACView if you have a fear of command prompts.
You have not set the PATH properly in DOS.You need to point the path to where the gacutil resides to use it in DOS.
运行 V2012 或任何已安装版本的开发人员命令提示符
在你的系统中
gacutil /i pathofDll
输入
Run Developer Command Prompt For V2012 or any version installed
in your system
gacutil /i pathofDll
Enter
如果在 Windows 7 上,gacutil.exe(将程序集放入 GAC 中)和 sn.exe(以确保程序集的唯一性)位于 C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin
然后转到gacutil 的路径如下所示,替换程序集的路径后执行以下命令
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin>gacutil /i "替换为要放置的程序集的路径进入广汽”
In case on windows 7 gacutil.exe (to put assembly in GAC) and sn.exe(To ensure uniqueness of assembly) resides at C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin
Then go to the path of gacutil as shown below execute the below command after replacing path of your assembly
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin>gacutil /i "replace with path of your assembly to be put into GAC"
也可以在 PowerShell 中使用 .NET Framework 程序集。
最近正在寻找一些解决方案,在我在这里找到相关信息之前测试了这个解决方案。
Also available using .NET Framework Assemblies in PowerShell.
Was searching some solution lately, tested this one before I found relevant info here.
上面的解决方案看起来很棒。但是,简单来说,我猜您需要的只是输入程序集名称及其完整路径,例如:
关注 C:\MyDlls\GacDeployedAssemblies
The above solutions look marvelous. However, to be simple, all you need I guess is to enter the assembly name along with its full path like:
Paying attention to C:\MyDlls\GacDeployedAssemblies
我几乎尝试了评论中的所有内容,但没有成功。所以我从 Powershell 中执行了
gacutil /i“path to my dll”
,它成功了。还要记住在 Windows 资源管理器中右键单击文件时按 Shift 键以获得“复制路径”选项的技巧。
I tried just about everything in the comments and it didn't work. So I did
gacutil /i "path to my dll"
from Powershell and it worked.Also remember the trick of pressing Shift when you right-click on a file in Windows Explorer to get the option of Copy path.
从
发布
选项卡转到应用程序文件
。然后,单击
不需要的文件
。之后,执行排除,按
ok
。最后,构建项目文件并运行项目。
From the
Publish
tab go toapplication Files
.Then, click
unnecessary files
.After that, do the exclude press
ok
.Finally, build the project files and run the projects.
要在 GAC 中添加 dll(例如 csvhelper.dll),您可以在 cmd 中使用以下命令。
C:\test>"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7 Tools\gacutil.exe" -i csvhelper.dll
**将您的 dll 放入文件夹中(例如在测试文件夹中)
**注意你有哪个版本的.Netframework(这里我使用.net4.7)
For adding your dll(for example csvhelper.dll) in GAC you can use the following command in cmd.
C:\test>"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7 Tools\gacutil.exe" -i csvhelper.dll
**Put your dll in a folder (for example in test folder)
**Pay attention which version of .Netframework you have(Here I used .net4.7)