.net 使用 Visual Studio 安装项目自动注册和 GAC 一个 COM Interop DLL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3087063/
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
Use Visual Studio Setup Project to automatically register and GAC a COM Interop DLL
提问by Ben McCormack
I've created a .NET assembly for COM interop and it is working well on my development machine. I'm currently trying to figure out how to deploy the DLL to a target machine using Visual Studio's "Setup Project." How can I use the VIsual Studio setup project to do the following things:
我已经为 COM 互操作创建了一个 .NET 程序集,它在我的开发机器上运行良好。我目前正在尝试弄清楚如何使用 Visual Studio 的“安装项目”将 DLL 部署到目标机器。如何使用 VIsual Studio 安装项目执行以下操作:
- Register the assembly (currently using
regasm).- The assembly needs to be registered successfully
and the type library (.tlb) needs to be registered successfully. - This answersuggests scrapping
regasmin favor of custom code. I this is a good idea? If so, how does this code get included in the setup project? - This answersuggests using the
/regfilecommand ofregasmand then using the import tool on the Registry in the Setup Project. Will this work?
- The assembly needs to be registered successfully
- Install the assembly in the GAC (currently using
gacutil)- I'm aware of the "Global Assembly Cache Folder" in the "File System on Target Machine." Is there anything special I need to do in including the assembly in the setup project?
- 注册程序集(当前使用
regasm)。 - 在 GAC 中安装程序集(当前使用
gacutil)- 我知道“目标机器上的文件系统”中的“全局程序集缓存文件夹”。在安装项目中包含程序集时,我需要做什么特别的事情吗?
Any other advice or concerns would be much appreciated.
任何其他建议或疑虑将不胜感激。
回答by Hans Passant
Gacutil.exe won't be available on the target machine. Not a problem, MSI can get the job done. Right-click "File System on Target Machine", Add, GAC. Right-click that added folder, Add, Project Output. That ensures the assembly is gac-ed.
Gacutil.exe 在目标机器上将不可用。没问题,MSI 可以完成工作。右键单击“目标机器上的文件系统”,添加,GAC。右键单击添加的文件夹,添加,项目输出。这确保了程序集是gac-ed。
It can also register the assembly like Regasm.exe does. Set the Register property of the project output reference to vsdrpCOM.
它还可以像 Regasm.exe 一样注册程序集。将项目输出引用的 Register 属性设置为 vsdrpCOM。

