C# 为什么我的参考的 Copy Local 属性被禁用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15526491/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 17:04:06  来源:igfitidea点击:

Why is the Copy Local property for my reference disabled?

c#visual-studiodll

提问by Clarice Bouwer

I am trying to set a referenced DLL to be explicitly copied to my local folder however when I go to the properties for this reference, the Copy Localproperty is grayed out / disabled.

我正在尝试将引用的 DLL 设置为显式复制到我的本地文件夹,但是当我转到此引用的Copy Local属性时,该属性变灰/禁用。

Disabled Copy Local property

禁用复制本地属性

Usually my VB.NET projects have a My Projectitem directly below the project name which I can double-click >> references and set the Copy Localproperty, however my C# console application does not seem to have this.

通常我的 VB.NET 项目My Project在项目名称正下方有一个项目,我可以双击 >> 引用并设置Copy Local属性,但是我的 C# 控制台应用程序似乎没有这个。

My Project References

我的项目参考

Have I perhaps configured my project incorrectly? Any help on this will be greatly appreciated.

我是否可能错误地配置了我的项目?对此的任何帮助将不胜感激。

采纳答案by StoriKnow

Directly from this SO post:

直接从这个SO帖子:

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 ?http://msdn.microsoft.com/en-us/library/dd409610.aspxIf you do want to deploy it though then will need to do the following ?Click on the reference in the references tab ?Hit F4 to bring up the properties grid ?Set "Embed Interop Types" to False (this will ungray Copy Local) ?Set "Copy Local" to true

您对 Hans 回答的评论表明这是一个 COM 程序集,并且您使用的是 Visual Studio 2010。

这意味着程序集引用可能是在“嵌入互操作类型”设置设置为 true 的情况下添加的。这具有将 COM 程序集链接到您的二进制文件的效果,无需完全部署它。下面的链接有更详细的解释吗?http://msdn.microsoft.com/en-us/library/dd409610.aspx如果您确实想部署它,则需要执行以下操作?单击参考选项卡中的参考?点击 F4 以显示属性网格?将“嵌入互操作类型”设置为 False(这将取消复制本地)?设置“本地复制”为真

If you want to copy local, you must set Embed Interop Typesto Falsefor the assembly, in your case, Microsoft.Office.Interop.Excel. Embed Interop Types makes deployment easier for COM assemblies in that it embeds the assemblies within your assembly, taking away the need to deploy interop assemblies with the application.

如果你想复制的地方,必须设置Embed Interop TypesFalse了大会,在你的情况,Microsoft.Office.Interop.Excel。嵌入互操作类型使 COM 程序集的部署更容易,因为它将程序集嵌入到您的程序集中,消除了使用应用程序部署互操作程序集的需要。