如何在 GAC 中注册 .NET DLL 文件?

发布于 2024-08-19 22:39:18 字数 505 浏览 2 评论 0原文

我制作了一个 .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 技术交流群。

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

发布评论

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

评论(13

陌上青苔 2024-08-26 22:39:18

您可以使用 gacutil 来完成此操作工具。最简单的形式是:

gacutil /i yourdll.dll

您可以在开始菜单中的程序 -> 下找到 Visual Studio 命令提示符。 Visual Studio -> Visual Studio 工具

You can do that using the gacutil tool. In its simplest form:

gacutil /i yourdll.dll

You find the Visual Studio Command Prompt in the start menu under Programs -> Visual Studio -> Visual Studio Tools.

萤火眠眠 2024-08-26 22:39:18

您需要:

  • 对程序集进行强命名(Visual Studio、项目属性、签名选项卡、对程序集进行签名)
  • 更改构建事件(项目属性、构建事件选项卡、构建后命令行)
   cd C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin
   gacutil.exe /i "$(TargetPath)" /f /nologo
   gacutil /l "$(TargetName)" /nologo

现在,每次构建项目时,它都会将安装在 GAC 上。

You'll need:

  • Strong name your assembly (Visual Studio, Project Properties, Signing tab, Sign the assembly)
  • Alter your Build Events (Project Properties, Build Events tab, Post-build command line)
   cd C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin
   gacutil.exe /i "$(TargetPath)" /f /nologo
   gacutil /l "$(TargetName)" /nologo

Now, everytime you build your project, it'll be installed on GAC.

眼眸印温柔 2024-08-26 22:39:18

只需使用 Windows 资源管理器将 DLL 文件拖放到文件夹 C:\Windows\ assembly 中即可。

注意事项:

在早期版本的 .NET Framework 中,Shfusion.dll Windows
shell 扩展允许您通过将程序集拖动到文件来安装程序集
探险家。从 .NET Framework 4 开始,Shfusion.dll 已过时。

来源:如何:将程序集安装到全局程序集中缓存

Just drag and drop the DLL file into folder C:\Windows\assembly using Windows Explorer.

Caveat:

In earlier versions of the .NET Framework, the Shfusion.dll Windows
shell extension let you install assemblies by dragging them to File
Explorer. Beginning with .NET Framework 4, Shfusion.dll is obsolete.

Source: How to: Install an assembly into the global assembly cache

沐歌 2024-08-26 22:39:18

这些响应并没有告诉您 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

神回复 2024-08-26 22:39:18

来自维基百科

gacutil.exe 是用于与 GAC 配合使用的 .NET 实用程序。

可以使用以下命令在 GAC 中检查共享程序集的可用性:

gacutil.exe /l "assemblyName"

可以使用以下命令在 GAC 中注册共享程序集:

gacutil.exe /i "assemblyName"

或者通过删除程序集文件使用 GUI 进入以下位置:

%windir%\assembly\

如果使用 /? 标志,将简要描述此实用程序的其他选项,即:

gacutil.exe /?

From Wikipedia:

gacutil.exe is the .NET utility used to work with the GAC.

One can check the availability of a shared assembly in GAC by using the command:

gacutil.exe /l "assemblyName"

One can register a shared assembly in the GAC by using the command:

gacutil.exe /i "assemblyName"

Or by dropping an assembly file into the following location using the GUI:

%windir%\assembly\

Other options for this utility will be briefly described if you use the /? flag, that is:

gacutil.exe /?
如痴如狂 2024-08-26 22:39:18

如果您害怕命令提示符,请尝试 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.

等待圉鍢 2024-08-26 22:39:18
  • 运行 V2012 或任何已安装版本的开发人员命令提示符
    在你的系统中

  • gacutil /i pathofDll

  • 输入

  • Run Developer Command Prompt For V2012 or any version installed
    in your system

  • gacutil /i pathofDll

  • Enter

也只是曾经 2024-08-26 22:39:18

如果在 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"

極樂鬼 2024-08-26 22:39:18

也可以在 PowerShell 中使用 .NET Framework 程序集。

[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
$publish = New-Object System.EnterpriseServices.Internal.Publish     
$publish.GacInstall("C:\path_to_dll_file\file.dll")

最近正在寻找一些解决方案,在我在这里找到相关信息之前测试了这个解决方案。

Also available using .NET Framework Assemblies in PowerShell.

[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
$publish = New-Object System.EnterpriseServices.Internal.Publish     
$publish.GacInstall("C:\path_to_dll_file\file.dll")

Was searching some solution lately, tested this one before I found relevant info here.

梓梦 2024-08-26 22:39:18

上面的解决方案看起来很棒。但是,简单来说,我猜您需要的只是输入程序集名称及其完整路径,例如:

gacutil -i C:\MyDlls\GacDeployedAssemblies\dllname.dll

关注 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:

gacutil -i C:\MyDlls\GacDeployedAssemblies\dllname.dll

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.

深者入戏 2024-08-26 22:39:18

发布选项卡转到应用程序文件

然后,单击不需要的文件

之后,执行排除,按ok

最后,构建项目文件并运行项目。

From the Publish tab go to application Files.

Then, click unnecessary files.

After that, do the exclude press ok.

Finally, build the project files and run the projects.

紫轩蝶泪 2024-08-26 22:39:18

要在 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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文