我在现有的MVC项目中升级到 ReportViewer 14.0 之后,我遇到了无法解决(或理解)的程序集冲突。
警告发现同一依赖程序集的不同版本之间存在冲突。 在Visual Studio中,双击此警告(或选择它并按Enter键)以修复冲突;否则,将以下绑定重定向添加到 应用程序配置文件中的“runtime”节点: NRM C:\ Program Files(x86)\ Microsoft Visual Studio \ 2017 \ Community \ MSBuild \ 15.0 \ Bin \ Microsoft.Common.CurrentVersion.targets 1964
它还说:
无法解决之间的冲突 “Microsoft.Build.Framework,Version = 14.0.0.0 ,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a”和 “Microsoft.Build.Framework,Version = 4.0.0.0 ,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a”。
如果我双击错误消息(如上所述),则将这些行添加到Web.Config:
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="14.0.0.0"/>
</dependentAssembly>
但这会在运行时创建此错误:
无法加载文件或程序集'Microsoft.Build.Framework, Version = 4.0.0.0 ,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'或 其中一个依赖项。系统找不到指定的文件。
如果我删除了Web.Config中的bindingRedirect,我只有警告但所有(包括ReportViewer 14.0)都能正常工作。
当我将Build-out更改为Diagnostic时,我会收到以下额外信息:
1> There was a conflict between "Microsoft.Build.Framework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". (TaskId:13)
1> No way to resolve conflict between "Microsoft.Build.Framework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing "Microsoft.Build.Framework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" arbitrarily. (TaskId:13)
1> References which depend on "Microsoft.Build.Framework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files (x86)\Reference Assemblies\Microsoft\MSBuild\v14.0\Microsoft.Build.Framework.dll]. (TaskId:13)
1> C:\Program Files (x86)\Reference Assemblies\Microsoft\MSBuild\v14.0\Microsoft.Build.Tasks.Core.dll (TaskId:13)
1> Project file item includes which caused reference "C:\Program Files (x86)\Reference Assemblies\Microsoft\MSBuild\v14.0\Microsoft.Build.Tasks.Core.dll". (TaskId:13)
1> Microsoft.ReportViewer.Design, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL (TaskId:13)
1> Microsoft.ReportViewer.WebDesign, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL (TaskId:13)
1> C:\Program Files (x86)\Reference Assemblies\Microsoft\MSBuild\v14.0\Microsoft.Build.Utilities.Core.dll (TaskId:13)
1> Project file item includes which caused reference "C:\Program Files (x86)\Reference Assemblies\Microsoft\MSBuild\v14.0\Microsoft.Build.Utilities.Core.dll". (TaskId:13)
1> Microsoft.ReportViewer.Design, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL (TaskId:13)
1> Microsoft.ReportViewer.WebDesign, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL (TaskId:13)
1> References which depend on "Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\Microsoft.Build.Framework.dll]. (TaskId:13)
1> D:\Dev\VS\--hidden-- (MVC)\NRM\packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.140.340.80\lib\net40\Microsoft.ReportViewer.WebForms.dll (TaskId:13)
1> Project file item includes which caused reference "D:\Dev\VS\--hidden-- Relatie Management (MVC)\NRM\packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.140.340.80\lib\net40\Microsoft.ReportViewer.WebForms.dll". (TaskId:13)
1> Microsoft.ReportViewer.WebDesign, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL (TaskId:13)
1> Microsoft.ReportViewer.WebForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL (TaskId:13)
在诊断日志中,还提到了以下冲突: