views:

329

answers:

2

How does .NET (or Visual Studio) build decide whether or not to copy a referenced assembly to your bin/debug or bin/release directory? (This is an .exe console program.)

On my machine, I had the referenced assembly in the GAC. A co-worker copied my bin/release to their machine, and it wouldn't run because the referenced asssembly was not in the bin/release (and not on their GAC).

Thanks,

Neal Walters

+4  A: 

If the assembly is not in GAC, then its copied. The CopyLocal attribute in properties window, tells if the assembly will be copied or not.

morpheus
+1. And as a side note, stay away from GAC'ing assemblies if you can. GAC is like the third level of DLL hell.
Chris Lively
This is a .DLL that we normally call from BizTalk, which requires it. A totally forgot about "CopyLocal". But is CopyLocal set to False by VisualStudio when the thing is in the GAC, otherwise true? Does it make any difference if you do the reference from the "Browse" tab vs the "Project" tab?
NealWalters
Also - what about if you reference the bin/debug of the .dll? Is that the only copy you will get in the bin/release of your .Exe?
NealWalters
is CopyLocal set to False by VisualStudio when the thing is in the GAC, otherwise true? Yes Does it make any difference if you do the reference from the "Browse" tab vs the "Project" tab? try it, but I don't think so. If you browse to GAC it knows the assembly is in GAC
morpheus
+1  A: 

When you have added a reference to a project (Project->Add Reference... or in Solution Explorer right click References and select Add Reference...) you can right click the added references and select Properties. You will then see the CopyLocal property in the properties window. This can be set to True or False to indicate weather the reference needs to be copied to the output directory of the project.

Thomas Wanner