问题描述
我试图将一些代码部署到客户端机器,我不想在其中安装 MS Windows SDK 工具.这意味着无法访问gacutil".我也没有为我的代码创建安装程序.似乎这可能是 .net 4.0 中仅有的两个选项.
I've trying to deploy some code to a client machine, where I don't want to install MS windows SDK tools. This means don't have access to "gacutil". I also have not created an installer for my code. It seems that these might be the only two options in .net 4.0.
过去我只是简单地开始,运行,输入程序集",然后将我的 dll 拖放到其中.
In the past I would simply go to start, run, type "assembly", and drag and drop my dll in.
这不再可能了吗?当我尝试这样做时,我没有收到错误消息,但 dll 没有出现在程序集"文件夹中.当我在我的开发机器上使用 gacutil 时它工作正常,但 dll 仍然没有出现.
Is this no longer possible? When I try to do this I get no error message, but the dll doesn't appear in the "assembly" folder. When I use gacutil on my dev machine it works properly, but the dll still doesn't appear.
推荐答案
在 .net 4.0 中,Microsoft 删除了只需通过拖放即可将 DLL 添加到程序集的功能.
In .net 4.0 Microsoft removed the ability to add DLLs to the Assembly simply by dragging and dropping.
相反,您需要使用 gacutil.exe,或创建一个安装程序来执行此操作.微软实际上不推荐使用 gacutil,但我还是选择了这条路线.
Instead you need to use gacutil.exe, or create an installer to do it. Microsoft actually doesn’t recommend using gacutil, but I went that route anyway.
要在开发机器上使用 gacutil,请访问:
开始 ->程序->Microsoft Visual Studio 2010 ->Visual Studio 工具 ->Visual Studio 命令提示符 (2010)
To use gacutil on a development machine go to:Start -> programs -> Microsoft Visual studio 2010 -> Visual Studio Tools -> Visual Studio Command Prompt (2010)
然后使用这些命令分别卸载和重新安装.注意我没有在卸载命令中包含 .dll
.gacutil/u myDLL
gacutil/i "C:Program FilesCustommyDLL.dll"
Then use these commands to uninstall and Reinstall respectively. Note I did NOT include .dll
in the uninstall command.gacutil /u myDLL
gacutil /i "C:Program FilesCustommyDLL.dll"
要在非开发机器上使用 Gacutil,您必须将可执行文件和配置文件从开发机器复制到生产机器.看起来 Gacutil 有几个不同版本.对我有用的那个,我在这里找到:C:Program Files (x86)Microsoft SDKsWindowsv7.0ABinNETFX 4.0 Toolsgacutil.exe
C:Program Files (x86)Microsoft SDKsWindowsv7.0ABinNETFX 4.0 Toolsgacutil.exe.config
To use Gacutil on a non-development machine you will have to copy the executable and config file from your dev machine to the production machine. It looks like there are a few different versions of Gacutil. The one that worked for me, I found here:C:Program Files (x86)Microsoft SDKsWindowsv7.0ABinNETFX 4.0 Toolsgacutil.exe
C:Program Files (x86)Microsoft SDKsWindowsv7.0ABinNETFX 4.0 Toolsgacutil.exe.config
将文件复制到此处或到相应的 .net 文件夹;C:WindowsMicrosoft.NETFrameworkv4.0.30319
Copy the files here or to the appropriate .net folder;C:WindowsMicrosoft.NETFrameworkv4.0.30319
然后使用这些命令分别卸载和重新安装"C:UsersBHJeremyDesktopInstalling to the Gac in .net 4.0gacutil.exe"/u "myDLL"
Then use these commands to uninstall and reinstall respectively"C:UsersBHJeremyDesktopInstalling to the Gac in .net 4.0gacutil.exe" /u "myDLL"
"C:WindowsMicrosoft.NETFrameworkv4.0.30319gacutil.exe"/i "C:Program FilesCustommyDLL.dll"
这篇关于将 DLL 拖放到 Windows Server 2008 .net 4.0 中的 GAC(“程序集")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!