Dot-Net

Microsoft.ReportViewer.Common 版本=12.0.0.0

  • October 20, 2020

我的 Windows 服務應用程序出現以下異常:

System.IO.FileNotFoundException:無法載入文件或程序集“Microsoft.ReportViewer.Common,Version=12.0.0.0,Culture=neutral,PublicKeyToken=89845dcd8080cc91”或其依賴項之一。該系統找不到指定的文件。

我找不到版本 12 的下載 url 並將文件設置為“包含”和“先決條件(自動)”並不能解決此 Windows 服務應用程序中的問題,儘管它在我的 WinForms 應用程序中工作正常並導致相應的文件被與所有其他必需的 .DLL 一起包含和引用。

有人可以幫我讓這個 Windows 服務應用程序包含這些文件,或者引導我到一個將在 GAC 中安裝版本 12 的下載連結嗎?

ReportViewer 位的第 12 版稱為Microsoft Report Viewer 2015 Runtime,可從以下連結下載安裝:

https://www.microsoft.com/en-us/download/details.aspx?id=45496

更新:

ReportViewer 位也可用作 NUGET 包:https ://www.nuget.org/packages/Microsoft.ReportViewer.Runtime.Common/12.0.2402.15

Install-Package Microsoft.ReportViewer.Runtime.Common

我在這個問題上工作了幾天。安裝了所有的包,修改了web.config,還是有同樣的問題。我終於刪除了

<assemblies>
<add assembly="Microsoft.ReportViewer.Common, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</assemblies>

從 web.config 並且它有效。不完全確定為什麼它不能與 web.config 文件中的標籤一起使用。我猜 GAC 和 BIN 文件夾有衝突。

這是我的 web.config 文件:

<?xml version="1.0"?>
<configuration>
 <system.web>
   <compilation debug="true" targetFramework="4.5" />
   <httpRuntime targetFramework="4.5" />
   <httpHandlers>
     &lt;add verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /&gt;     
   &lt;/httpHandlers&gt;    
 &lt;/system.web&gt;
 &lt;system.webServer&gt;
   &lt;validation validateIntegratedModeConfiguration="false" /&gt;
   &lt;handlers&gt;
     &lt;add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /&gt;      
   &lt;/handlers&gt;
 &lt;/system.webServer&gt;
&lt;/configuration&gt;

引用自:https://stackoverflow.com/questions/31169514