当我清理并构建具有多个项目的解决方案时,输出窗口将报告构建成功。然而,当我查看错误列表窗口时,它向我显示了这样的警告:

发现同一依赖程序集的不同版本之间存在无法解决的冲突。当日志详细信息设置为detailed时,这些引用冲突将在生成日志中列出。C:\Program Files (x86)\MSBuild\12.0\bin\ Microsoft.Common.CurrentVersion.targets

当我双击此消息时,它将打开C:\Program Files (x86)\MSBuild\12.0\bin\ Microsoft.Common.CurrentVersion。目标文件,但我不明白任何东西在它。

我正在使用Visual Studio Express 2013的Web。

我如何找出什么是错误的,与哪个DLL,然后我如何使警告消失?


当前回答

我正在使用Visual Studio 2017,在更新一些Nuget包时遇到了这个问题。对我有用的是打开我的网。config文件,找到<runtime><assemblyBinding>节点并删除它。保存网页。配置并重新构建项目。

查看错误列表窗口。您将看到一个关于绑定冲突的非常长的警告。双击它,它将自动用正确的映射重新创建<runtime><assemblyBinding>块。

其他回答

重申@elshev的评论 右键单击解决方案->管理解决方案->的NuGet包在巩固下,你可以看到是否有不同版本的相同的包被安装。在那里更新包。解决冲突错误。

我可以解决这个问题,在web项目中安装Newtonsoft Json

I found that, sometimes, nuget packages will install (what I'm guessing are) .NET Core required components or other items that conflict with the already-installed framework. My solution there was to open the project (.csproj) file and remove those references. For example, System.IO, System.Threading and such, tend to be added when Microsoft.Bcl is included via some recently installed NuGet package. There's no reason for specific versions of those in my projects, so I remove the references and the project builds. Hope that helps.

您可以在项目文件中搜索“参考”并删除冲突。如果它们包含在系统中,那么去掉它们,构建应该可以工作。这可能不能回答这个问题的所有情况-我确保你知道什么对我有用:)

我注释掉的例子:

< !<参考Include=“系统。”Runtime,版本=2.6.9.0,Culture=neutral, PublicKeyToken= b03f5f7f3a, processorArchitecture=MSIL"> -> < !- <HintPath>$(解决方案)packages\Microsoft.Bcl.1.1.9\lib\net40\系统. runtpath > < !<Private>True</Private> -> < !</参考> ->

在迁移到Package Reference之后,我收到了这个警告。在诊断输出中,有同一库本身引用了该库的信息。这可能是一个新的包引用的错误。解决方案是启用AutoGenerateBindingRedirects并删除自定义绑定重定向。

我将MSBuild详细信息更改为诊断。但是找不到问题在哪里,所以根据上面的答案,我在app.config中有这样的代码:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="XbimXplorer.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>

所以我只是把第一个系统的版本从4.0.0.0改为12.0.0.0,我的项目工作了。