我有一個程序集衝突,我在現有的MVC項目中升級到ReportViewer 14.0後無法解決(或理解)。安裝後的程序集衝突Microsoft.ReportingServices.ReportViewerControl.WebForms
警告在同一相關程序集的不同版本之間發現衝突。 在Visual Studio中,雙擊此警告(或選擇它並按Enter鍵)以解決衝突;否則,將以下綁定重定向添加到應用程序配置文件中的 「運行時」節點: NRM C:\ Program Files(x86)\ Microsoft Visual Studio \ 2017 \ Community \ MSBuild \ 15.0 \ Bin \ Microsoft.Common .CurrentVersion.targets 1964年
它還說:
沒有辦法之間 「Microsoft.Build.Framework,版本= 14.0.0.0 ,文化=中性公鑰= 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, 版本= 4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'或 其依賴項之一。該系統找不到指定的文件。
如果我刪除Web.Config中的bindingRedirect,我只有警告,但所有(包括ReportViewer 14.0)工作正常。
當我改變構建出以診斷,我接受這些額外的信息:
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)
在診斷日誌,還有用於提及衝突:
- System.Net
- Microsoft.Build.Framework
- mscorlib
- System.Core
- 系統
你是通過NuGet安裝的嗎?我做了,我沒有運行時錯誤,即使我也有2「無法解決衝突」的消息。但是我使用VS 2015(您使用2017)。你打算如何在你的項目中使用ReportViewer?據我所知它不能在.CSHTML頁面上顯示任何內容(它只與Web表單兼容)。在我的情況下,我只需要.PDF和我的報告在遠程模式下運行。 –
嗨@JoeSchmoe,是的,我用過NuGet。我已經解決了,但現在我不知道我是如何做到的。笨!我用它來創建代碼中的PDF(在控制器中),並將文件作爲FileStreamResult返回給客戶端。這樣您就可以在瀏覽器中顯示它,或者強制瀏覽器將其作爲文件下載。所以我使用Web控件來渲染PDF文件,而不是顯示它。它工作得很好。 – roberth