3
votes

I have assembly conflicts that I can't solve (or understand) after I've upgraded to ReportViewer 14.0 in an existing MVC-project.

Warning Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file: NRM C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets 1964

It also says:

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".

If I double-click the error message (as it says) it adds these lines to 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>

But this creates this error at runtime:

Could not load file or assembly 'Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

If I remove the bindingRedirect in Web.Config I only have the warning but all (including ReportViewer 14.0) works fine.

When I change Build-out to Diagnostic, I receive this extra information:

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)

In the diagnostic log, there are also conflicts mentioned for:

  • System.Net
  • Microsoft.Build.Framework
  • mscorlib
  • System.Core
  • System
1
Did you install it via NuGet? I did and I don't have runtime error even though I also have 2 "No way to resolve conflict" messages. However I use VS 2015 (you use 2017). How do you intend to use ReportViewer in your project? As far as I know it cannot render anything on .CSHTML page (it is only compatible with web forms). In my case I only need .PDF and my report runs in remote mode.Joe Schmoe
Hi @JoeSchmoe, Yes I used NuGet. I have solved it but now I'm not sure how I did it. Stupid! I use it to create a PDF in code (in the controller) and return the file as a FileStreamResult to the client. That way you can show it in the browser or force the browser to download it as a file. So I use the web-control to render the PDF-file, not to display it. It works very well.roberth

1 Answers

3
votes

I got the error today again.

It happened when I added ReportViewer through NuGet while I had added those reference in the past manually. I cleared the manual reference but this didn't clear the Web.Config enough. In the process I also updated other packages which might have to do with it.

I solved the issue by cleaning these lines from Web.Config.

enter image description here