Question

Many similar posts but this is not a duplicate I believe. When I add references in visual studio, some dlls are copied locally while some not.

I understand that the external dlls I get from elsewhere should have a local reference, but then I suppose the ones I choose from Visual Studio's long list of references (.NET and COM) need not be copied locally. I do not.

Now I noticed that when I choose Shell32 from COM dll is copied locally. By default "Copy Local" is set to true. So I assumed .NET are the ones that need not have a local reference while COM should have. But when I referenced Office Interop objects (COM) I see that they are not copied locally.

  1. How is that some are copied locally and some not. (trying to know something nice)

  2. Also how should I go about setting "Copy Local" property for references generally? Is it recommended just to go by what Visual Studio does by default?

Thanks.

Was it helpful?

Solution

The odds that VS gets this wrong by default are quite small. Your dev machine is (normally) not that different from your user's machine, what matters is what is in your GAC. You'll have .NET installed just like the user so framework assemblies are in the your GAC as well as the user's so don't get copied local. Any 3rd party .NET assembly gets copied local, including your own.

The only corner case are COM pias, Primary Interop Asssemblies. You tend to have some installed on your dev machine, the Office and Internet Explorer pias are fairly common. They won't be available on the user's machine unless somebody takes care of installing them. It is not often that you actually need a pia, they are only required when your own assembly exposes a type from them. Just flip Copy Local to True. This is otherwise a rapidly disappearing problem, projects built by VS2010 supports the Embed Interop Types feature, otherwise known as the "no-pia" goody.

Last but not least, you always need to test your installer. In the unlikely case you missed something, that test will rapidly flush it out.

OTHER TIPS

I use it to control what gets published into the build output. If the reference is something that needs to be deployed privately I set it to true. Otherwise, I set it to false.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top