Asp.net VS2010中ReportViewer程序集的问题
我将VisualStudio2010中的ReportViewer 10.0.0.0用于我的Web应用程序,但它的程序集出现问题。 服务器上安装了ReportViewer 8.0.0.0和9.0.0.0,我试图避免安装10.0.0.0版本 我在想,即使没有安装ReportViewer10 dll,也可以在服务器上使用它。我将DLL的Asp.net VS2010中ReportViewer程序集的问题,asp.net,visual-studio-2010,dll,assemblies,reportviewer,Asp.net,Visual Studio 2010,Dll,Assemblies,Reportviewer,我将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,以便将它们复制到output bin文件夹。属性复制到输出目录为不复制 如以下错误所示,我的项目正在ReportVie
Build Action
属性设置为Content
,以便将它们复制到output bin文件夹。属性复制到输出目录
为不复制
如以下错误所示,我的项目正在ReportViewer中查找两个程序集,一个在GAC中,另一个在临时ASP.NET文件中。搜索时,我还发现,每次向服务器请求时,都会重新生成临时ASP.NET文件
为了解决我的问题,我从临时ASP.NET文件
中删除了dll,整个应用程序停止工作,表明我的应用程序使用的是临时ASP.NET文件
中的dll,而不是GAC或bin文件夹中的dll。我想将我的应用程序设置为使用bin文件夹中的dll或临时ASP.NET文件
,因为在这些地方,dll的版本是正确的(10.0.0.0)。下面的错误显示了来自GAC的ReportViewer9 DLL和来自临时ASP.NET文件的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
通过执行以下操作解决了我的问题:
我留下DLL供我的项目引用,但我已将它们从bin文件夹中删除。这样,dll将停止在临时ASP.NET文件文件夹中重新生成,从而结束冲突:
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文件有任何关系