10

我在网站中使用 MS ReportViewer 组件已有一段时间了,但最近我收到了如下所示的错误。

解析器错误消息:基类包含字段“xyz”,但其类型 (Microsoft.Reporting.WebForms.ReportViewer) 与控件类型 (Microsoft.Reporting.WebForms.ReportViewer) 不兼容。

<rsweb:ReportViewer ID="xyz" runat="server" Width="100%" Font-Names="Verdana" Font-Size="8pt" Height="400px" ProcessingMode="Local" ShowExportControls="false">

现在,我在 Visual Studio 和生产环境中都遇到了这个错误。我在生产中安装了 ReportViewer Redistributable。

我是否以某种方式错过了我的项目中的参考资料,或者其他什么?

4

8 回答 8

6

我找到了答案:以某种方式对 Microsoft.Reporting.WebForms 版本 9 的引用切换到了版本 8。这导致了错误。因此,删除引用并添加正确版本的引用似乎已经解决了问题。

编辑:

好吧,根据以前版本的 .vbproj 文件,它是对 9 的引用,尽管项目引用属性屏幕告诉我 8。简而言之,我不太确定是什么搞砸了,但似乎现在正在工作。

如果有人经历过或有一些见解,请贡献。

于 2009-05-04T14:49:55.953 回答
2

全新安装后,我的项目没有编译,因为对 dll 的引用已损坏,所以我将其删除并再次添加,然后使用 ReportViewer 的网页出现解析器错误:

The base class includes the field 'rprtReportsViewer', but its type (Microsoft.Reporting.WebForms.ReportViewer) is not compatible with the type of control (Microsoft.Reporting.WebForms.ReportViewer).

我在网页上找到了与我刚刚添加的版本号不同的参考:

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

我把版本改成了9.0.0.0,这次刷新页面时出现编译错误:

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

然后我搜索了“Microsoft.ReportViewer”的解决方案,并在compile.config中找到了更多参考:

    <add assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
    <add assembly="Microsoft.ReportViewer.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
  </assemblies>
  <buildProviders>
    <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </buildProviders>

我也在这里更改了版本号,它停止了错误

于 2011-03-31T10:20:20.740 回答
2

您可能还需要从 \bin 文件中删除:

     Microsoft.ReportViewer.Common.dll
     Microsoft.ReportViewer.ProcessingObjectModel.dll
     Microsoft.ReportViewer.WebForms.dll
     Microsoft.ReportViewer.WinForms.dll

我只是将它们移到一个子目录中。

于 2012-07-24T15:39:29.530 回答
2

检查您的页面 rdlc 版本,例如

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
于 2014-10-14T06:14:34.937 回答
0

有同样的问题。使用 SQL Server 2005 和 SQL 报告清理 Windows 2008 Server 安装。服务器托管该站点。已安装 ReportViewer 2008 SP1。Web.config 引用版本 9.0.0.0。

出现相同的错误消息:基类包含该字段,但其类型 (Microsoft.Reporting.WebForms.ReportViewer) 与控件类型 (Microsoft.Reporting.WebForms.ReportViewer) 不兼容。

网上搜了一下,很多人都遇到过同样的问题。有人建议手动编辑项目文件。我设法通过在解决方案资源管理器->[Web 项目名称]->参考->Microsoft.Reporting.WebForms->属性中设置特定版本 = True (Version=9.0.0.0) 来修复它。

在其中一种环境中,我们还在 web bin 文件夹中找到了 Microsoft.Reporting dll。而且,它们与在 GAC 中注册的 dll 冲突。删除 dll 解决了这个问题。

于 2009-07-10T17:23:25.683 回答
0

我在生产服务器上遇到了这个问题。我安装了正确版本的 ReportViewer,并确保项目中的所有引用都指向正确的版本。但是,我仍然遇到错误。

最终,我通过转到“临时 ASP.NET 文件”并删除我的应用程序的文件来解决了这个问题。为此,您需要先停止该应用程序。这然后解决了这个问题。在 DEV 服务器上我没有遇到这个问题,因为安装 ReportViewer 后我重新启动了机器。

希望这可以帮助某人。在解决这个特殊的“挑战”之前,我拔掉了很多头发。

于 2014-01-17T11:15:42.100 回答
0

References -> (Microsoft.ReportViewer.WebForms),点击鼠标右键。

指定版本选项,将其保留为 false。

之后,只需保存并再次运行。

于 2014-04-09T16:01:34.487 回答
-2

我遇到了同样的错误。对我有用的是删除引用 Microsoft.ReportViewer.WebForms 并再次添加它。

于 2016-11-07T10:01:24.557 回答