【问题标题】:Problems with ReportViewer assemblies in VS2010VS2010 中 ReportViewer 程序集的问题
【发布时间】:2012-03-14 19:35:21
【问题描述】:

我正在将 VisualStudio2010 中的 ReportViewer 10.0.0.0 用于我的 Web 应用程序,但它的程序集出现问题。 服务器安装了 ReportViewer 8.0.0.0 和 9.0.0.0,我试图避免安装 10.0.0.0 版本。

我在考虑是否可以在服务器上使用 ReportViewer10 dll,即使没有安装它。我将 dll 的 Build Action 属性设置为 Content,以便将它们复制到输出 bin 文件夹。属性Copy to Output DirectoryDo not copy

如以下错误所示,我的项目正在从 ReportViewer 中找到两个程序集,一个在 GAC 中,另一个在 Temporary ASP.NET Files 中。搜索,我也发现Temporary ASP.NET Files 是重新生成每个对服务器的请求。

为了解决我的问题,我从Temporary ASP.NET Files 中删除了 dll,整个应用程序停止工作,这表明我的应用程序正在使用来自 Temporary ASP.NET Files 的 dll,而不是来自 GAC 或 bin 文件夹。我想将我的应用程序设置为使用 bin 文件夹或 Temporary ASP.NET Files 中的 dll,因为在这些地方,dll 的版本正确(10.0.0.0)。下面的错误显示来自 GAC 的 ReportViewer9 dll 和来自 Temporary ASP.NET Files 的 ReportViewer10 dll 之间存在冲突。

An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

CS0433: The type 'Microsoft.Reporting.WebForms.ReportViewer' exists in both
'c:\\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\9.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll' and 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\project\4ec9147f\d072b522\assembly\dl3\662a86a1\009c93d3_afeccc01\Microsoft.ReportViewer.WebForms.DLL'

Line 180:
Line 181: [System.Diagnostics.DebuggerNonUserCodeAttribute()]
Line 182: private global::Microsoft.Reporting.WebForms.ReportViewer @__BuildControlReportViewer1() {
Line 183:    global::Microsoft.Reporting.WebForms.ReportViewer @__ctrl;
Line 184: 

Source File: C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\project\4ec9147f\d072b522\App_Web_default.aspx.cdcab7d2.dmkwuxko.0.cs 
Line: 182

【问题讨论】:

    标签: asp.net visual-studio-2010 dll assemblies reportviewer


    【解决方案1】:

    通过执行以下操作解决了我的问题:

    我保留了我的项目引用的 dll,但我已将它们从 bin 文件夹中删除。这样,dll 就不会在 Temporary ASP.NET Files 文件夹中重新生成,从而结束冲突:

     CS0433: The type 'Microsoft.Reporting.WebForms.ReportViewer' exists in both
    'c:\\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\9.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll' and 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\project\4ec9147f\d072b522\assembly\dl3\662a86a1\009c93d3_afeccc01\Microsoft.ReportViewer.WebForms.DLL'
    

    报告查看器一直无法正常工作,这与预期的一样(GAC 只有版本 8 和 9 的 dll)。然后在服务器上安装了 Report Viewer 10.0.0.0,这次又出现了一个新的错误:

        CS0433: The type 'Microsoft.Reporting.WebForms.ReportViewer' exists in both
    'c:\\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\9.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll' and 'c:\\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\10.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll' 
    

    我觉得奇怪的是不同版本的dll之间发生了这种冲突,这次的解决方案是在web.config文件中添加以下标签:

        <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" appliesTo="v2.0.50727">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.ReportViewer.WebForms" publicKeyToken="b03f5f7f11d50a3a"/>
        <bindingRedirect oldVersion="9.0.0.0" newVersion="10.0.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
    

    完成。它工作没有任何冲突,并且可以导出报告。

    我的问题已经解决了,但我还有一个疑问,希望有人帮我解决这个问题:

    为什么服务器在不同版本的 GAC_MSIL 中的两个 dll 之间会发生冲突?服务器不应该只查找我在项目中引用并在 Web.config 中指定的版本吗? (10.0.0.0)

    和machine.config文件有关系吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-20
      • 1970-01-01
      相关资源
      最近更新 更多