在VS 2010中使用ReportViewer 9控件

时间:2010-06-10 09:22:05

标签: visual-studio-2010 reporting-services reportviewer reportingservices-2005

我正在编写一个使用带有SSRS设置的SQL Server 2005的ASP.NET应用程序。我想使用ReportViewer控件但是在使用ReportViewer 10时出现错误,因为它需要SSRS 2008。

如何在我的应用程序中使用ReportViewer 9。我添加了对Microsoft.ReportViewer.WebForms.dll版本9的引用,并删除了对版本10的引用。

我的标记如下:

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<!-- standard markup -->
<rsweb:ReportViewer ID="ReportViewer1" runat="server"></rsweb:ReportViewer>

但是当我尝试运行时,我收到以下错误:

  

CS0433:类型   'Microsoft.Reporting.WebForms.ReportViewer'   存在于两者中   'C:\ Windows \组件\ GAC_MSIL \ Microsoft.ReportViewer.WebForms \ 10.0.0.0__b03f5f7f11d50a3a \ Microsoft.ReportViewer.WebForms.dll'   和   'C:\ Windows \组件\ GAC_MSIL \ Microsoft.ReportViewer.WebForms \ 9.0.0.0__b03f5f7f11d50a3a \ Microsoft.ReportViewer.WebForms.dll'

我错过了什么!?

更新 尝试使用ReportViewer 10时,出现以下错误:

  

“远程报告处理需要   Microsoft SQL Server 2008报告   服务或以后。“

2 个答案:

答案 0 :(得分:13)

想出来,忘了在web.config文件中更改3个引用:

在HttpHandler中:

<add verb="*" path="Reserved.ReportViewerWebControl.axd" type = "Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

并在程序集中:

<add assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />

答案 1 :(得分:2)

不知道为什么,但你应该尝试,如果这工作: 将以下代码添加到web.config

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

之前

</configuration>

它对我有用