2017-01-10 95 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