【问题标题】:The type 'Microsoft.Reporting.WebForms.ReportViewer' exists in both'Microsoft.Reporting.WebForms.ReportViewer' 类型存在于两者中
【发布时间】:2014-10-30 03:32:30
【问题描述】:

我有一个引用 Microsoft.ReportViewer.WebForms 版本 9.0.0.0 的 ASP.NET 应用程序,我改为引用版本 11.0.0.0 的 Microsoft.ReportViewer.WebForms。现在,当我在 2 台机器上运行我的应用程序时,出现以下错误

编译错误

说明:在编译服务此请求所需的资源时出错。请查看以下特定错误详细信息并适当修改您的源代码。

编译器错误消息: CS0433:“Microsoft.Reporting.WebForms.ReportViewer”类型存在于“c:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\9.0.0.0__b03f5f7f11d50a3a”中\Microsoft.ReportViewer.WebForms.dll' 和 'c:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\11.0.0.0__89845dcd8080cc91\Microsoft.ReportViewer.WebForms.DLL'

我已确保我的 web.config 版本号中的所有位置都更新为 11.0.0.0

【问题讨论】:

    标签: asp.net


    【解决方案1】:

    我尝试在 web.config 中添加dependentAssembly,但没有帮助。

    <dependentAssembly>
      <assemblyIdentity name="Microsoft.ReportViewer.WebForms" publicKeyToken="89845dcd8080cc91" />
      <bindingRedirect oldVersion="8.0.0.0-10.0.0.0" newVersion="11.0.0.0" />
    </dependentAssembly>
    

    但是它没有帮助,因为 PublicKeyToken 在 11.0.0.0 dll 中发生了变化。

    最后我能够通过在 web.config 中添加qualifyAssembly 节点来解决问题

    <qualifyAssembly partialName="Microsoft.ReportViewer.WebForms" fullName="Microsoft.ReportViewer.WebForms,version=11.0.0.0,culture=neutral,publicKeyToken=89845dcd8080cc91" />
    

    【讨论】:

    • 对于任何想知道的人,qualifyAssembly 在运行时和您的 webconfig 中的程序集绑定中进行:&lt;runtime&gt;&lt;assemblyBinding&gt;&lt;qualifyAssembly /&gt;&lt;/assemblyBinding&gt;&lt;/runtime&gt;
    【解决方案2】:

    我的解决方案。 我在 _bin_deployableAssemblies 文件夹中有旧版本的 ReportViewer。我从中删除了所有内容,并使用了“packages\Microsoft.ReportViewer.11.0.3366.16\lib”文件夹中的引用。

    【讨论】:

      猜你喜欢
      • 2012-06-29
      • 1970-01-01
      • 1970-01-01
      • 2015-11-01
      • 2014-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多