我正在使用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 Directory
为Do 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文件夹中的dll或Temporary ASP.NET Files
,因为在这些地方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
答案 0 :(得分: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'
报告查看器无法正常工作,预期如何(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文件有任何关系?