VS2010中的ReportViewer程序集问题

MMa*_*lke 4 dll reportviewer assemblies visual-studio-2010

我正在使用VisualStudio2010中的ReportViewer 10.0.0.0进入我的Web应用程序,我遇到了它的程序集问题.服务器安装了ReportViewer 8.0.0.0和9.0.0.0,我试图避免安装10.0.0.0版本.

我在想是否可以在服务器上使用ReportViewer10 dll甚至没有安装它.我设置了Build Actiondll 的属性,以便Content将它们复制到输出bin文件夹.该物业Copy to Output DirectoryDo not copy.

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

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

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
Run Code Online (Sandbox Code Playgroud)

MMa*_*lke 6

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

我离开了我的项目引用的dll但我已经从bin文件夹中删除了它们.这样,在Temporary ASP.NET Files文件夹中停止重新生成dll,结束冲突:

 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'
Run Code Online (Sandbox Code Playgroud)

报告查看器保持不工作,预期如何(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' 
Run Code Online (Sandbox Code Playgroud)

我认为这种冲突发生在不同版本的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>
Run Code Online (Sandbox Code Playgroud)

完成.它没有任何冲突,可以导出报告.

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

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

它与machine.config文件有任何关系吗?