Visual Studio 将 dll 引用复制到输出文件夹
我正在尝试扩展某个应用程序。我正在使用与该应用程序捆绑在一起的 DLL 来扩展其功能。我使用的是 Visual Studio 2010 Express 版本。我添加了对 dll 库的引用。在参考属性中,“复制本地”选项被禁用。(灰显)这是为什么?我希望 Visual Studio 将 dll 复制到我的发布文件夹中。如果这不能完成,还有其他方法来捆绑 dll 吗?
I am trying to extend a certain application. I am using a DLL which comes bundled with that application to extend its functionality. I am using visual studio 2010 express edition. I added a reference to the dll library. In the reference properties the option "Copy local" is disabled.(greyed out) why is that? I want visual studio to copy the dll to my release folder. If this can't be done is there another way to bundle the dll?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您对 Hans 回答的评论表明这是一个 COM 程序集,并且您正在使用 Visual Studio 2010。
这意味着程序集引用可能是在“嵌入互操作类型”设置设置为 true 的情况下添加的。这具有将 COM 程序集链接到二进制文件中的效果,从而无需完全部署它。以下链接有更详细的说明
如果您确实想部署它,则需要执行以下
Your comment to Hans answer indicates this is a COM assembly and that you are using Visual Studio 2010.
This means the assembly reference was likely added with the "Embed Interop Types" setting set to true. This has the effect of linking the COM assembly into your binary removing the need to deploy it altogether. The following link has a more detailed explanation
If you do want to deploy it though then will need to do the following
这取决于它是什么类型的DLL。如果它是 COM 服务器,则当您为该 COM 服务器注册了 PIA 时,“复制本地”将关闭。如果它是常规 .NET 程序集,则在 GAC 中注册时它将关闭。
通过分别使用 regasm /u 取消注册 PIA 或 gacutil /u 将其从 GAC 中删除来修复该问题。请注意,如果此 DLL 要求其安装程序在目标计算机上执行,您可能不想执行此操作。这很有可能。与组件供应商或作者联系以了解您应该做什么。
It depends on what kind of DLL it is. If it is a COM server then Copy Local is off when you have a PIA registered for that COM server. If it is a regular .NET assembly then it will be off when it is registered in the GAC.
Fix the issue by, respectively, using regasm /u to unregister the PIA or gacutil /u to remove it from the GAC. Do note that you might not want to do this if this DLL requires that its installer is executed on the target machine. Which is likely. Talk to the component vendor or author to find out what you should do.