Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reference DLL file not copying to bin with deployment project, causing error

We have several external DLL files being referenced in our Web Application Project. We have a deployment project for installing on the hosting servers. When we were using .NET 3.5 and Visual Studio 2008 the DLL files were being copied to the bin folder. Since we have upgraded to .NET 4 and Visual Studio 2010 this no longer happens, and we are getting server errors since the references cannot be found.

CopyLocal is set to true, and I cannot find anything inside the web.config which suggests this is being set elsewhere.

like image 694
g.foley Avatar asked Jun 01 '10 02:06

g.foley


People also ask

How do I add a DLL to a VB NET project?

In Solution Explorer, double-click the My Project node for the project. In the Project Designer, click the References tab. Click the Add button to open the Add Reference dialog box. In the Add Reference dialog box, select the tab indicating the type of component you want to reference.


1 Answers

There is a bug in Visual Studio 2010. By default the XML in the solution file looks like this:

<Reference Include="DevExpress.SpellChecker.v11.1.Core,            Version=11.1.5.0,            Culture=neutral,            PublicKeyToken=b88d1754d700e49a,            processorArchitecture=MSIL"> <HintPath>..\References\DevExpress.SpellChecker.v11.1.Core.dll</HintPath> </Reference> 

Whereas MSBuild is expecting this below, so that the DLL file will be included in the deployment:

<Reference Include="DevExpress.SpellChecker.v11.1.Core,            Version=11.1.5.0,            Culture=neutral,            PublicKeyToken=b88d1754d700e49a,            processorArchitecture=MSIL"> <HintPath>..\References\DevExpress.SpellChecker.v11.1.Core.dll</HintPath> <Private>True</Private> </Reference> 

The trick is to set Copy Local to False, save the project and then reset it to True - save again. This includes the Private node correctly, which MSBuild respects.

It appears that the default for no included private node (Copy Local) in Visual Studio 2010 is True, while MSBuild reads that missing node as False.

like image 92
Rebecca Avatar answered Oct 13 '22 10:10

Rebecca