Why is the Copy Local property for my reference di

2019-02-02 05:20发布

问题:

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 Local property is grayed out / disabled.

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

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

回答1:

Directly from this SO post:

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.aspx If 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

If you want to copy local, you must set Embed Interop Types to False for 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.