引用 DLL 文件未与部署项目一起复制到 bin,导致错误 [英] Reference DLL file not copying to bin with deployment project, causing error

查看:18
本文介绍了引用 DLL 文件未与部署项目一起复制到 bin,导致错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的 Web 应用程序项目中引用了多个外部 DLL 文件.我们有一个用于在托管服务器上安装的部署项目.当我们使用 .NET 3.5 和 Visual Studio 2008 时,DLL 文件被复制到 bin 文件夹中.由于我们已升级到 .NET 4 和 Visual Studio 2010,这种情况不再发生,而且由于找不到引用,我们收到了服务器错误.

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 设置为 true,我在 web.config 中找不到任何表明它在其他地方设置的内容.

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

推荐答案

Visual Studio 2010 中存在一个错误.默认情况下,解决方案文件中的 XML 如下所示:

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>

而 MSBuild 期望在下面这样做,以便 DLL 文件将包含在部署中:

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>

诀窍是将Copy Local设置为False保存项目,然后将其重置为True- 再次保存.这正确地包括了私有节点,MSBuild 尊重它.

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.

似乎 Visual Studio 2010 中不包含私有节点(Copy Local)的默认值为 True,而 MSBuild 将该缺失节点读取为 False.

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.

这篇关于引用 DLL 文件未与部署项目一起复制到 bin,导致错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆