2017-01-10 100 views
0

當我想用Visual Studio運行報表查看器時,它會導致以下錯誤。SSRS - Report Viewer編譯錯誤

============================================== =========================== 編譯錯誤

說明:在編譯爲請求提供服務所需的資源編譯期間發生錯誤。請查看以下具體的錯誤細節並適當修改您的源代碼。

Compiler Error Message: CS0433: The type 'Microsoft.Reporting.WebForms.ReportViewer' exists in both 'c:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\10.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll' and 'c:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\11.0.0.0__89845dcd8080cc91\Microsoft.ReportViewer.WebForms.DLL'

源錯誤:

[System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     private global::Microsoft.Reporting.WebForms.ReportViewer @__BuildControlReportViewerSummary() { 
      global::Microsoft.Reporting.WebForms.ReportViewer @__ctrl; 

是不是意味着我缺少.dll文件???

謝謝。

回答

0

這個問題是完全無關的丟失的DLL文件,而應該與相同的ReportViewer命名空間存在於同一目錄(%Windows%\ assembly)的不同DLL文件中。請嘗試以下解決方案:

  1. 檢查的ReportViewer舊版本中_bin_deployableAssemblies目錄。刪除與之相關的所有文件,並使用Microsoft.ReportViewer.11.0參考。

  2. 檢查web.config文件中Microsoft.ReportViewer.WebForms命名空間的重複聲明,如果存在,則刪除較舊的命名空間。

  3. 添加qualifyAssembly元素在web.config文件:

    <qualifyAssembly partialName="Microsoft.ReportViewer.WebForms" fullName="Microsoft.ReportViewer.WebForms,version=11.0.0.0,culture=neutral,publicKeyToken=89845dcd8080cc91" /> 
    
  4. 如果問題仍然存在,刪除相關Microsoft.ReportViewer.WebForms命名空間,乾淨的整個解決方案(刪除參考舊版本的DLL文件)的所有引用,加使用最新版本的新參考然後重新生成解決方案文件。此外,您可能會嘗試從彙編目錄中刪除/卸載衝突的DLL文件之一。

注:請記住,這兩個版本(10.0 & 11.0)有不同的PublicKeyToken屬性值,因此bindingRedirect絕招dependentAssembly節點不起作用。

相關問題與CS0433:

C#: The type 'Microsoft.Reporting.WebForms.ReportViewer' exists in both ReportingServicesWebUserInterface.dll and Microsoft.ReportViewer.WebForms.dll

The type 'Microsoft.Reporting.WebForms.ReportViewer' exists in both