Microsoft ASP.NET ReportViewer Parser Error

2019-06-15 18:29发布

问题:

I've been using a MS ReportViewer component in a website for a while now, but recently I've been getting the error shown below.

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

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

Now, I get this error in Visual Studio as well as in production. I have the ReportViewer Redistributable installed in production.

Am I somehow missing a reference in my project, or something?

回答1:

I discovered the answer: Somehow the reference to version 9 of Microsoft.Reporting.WebForms got switched to version 8. This caused the error. So deleting the reference and adding in the correct version of the reference seems to have fixed the problem.

Edit:

Well, according to the previous version of the .vbproj file, it was a reference to 9, despite that the project references properties screen told me 8. In short I'm not really sure what managed to get screwed up, but it seems to be working now.

If anyone has experienced this or has some insight, please contribute.



回答2:

Following a clean install, my project didn't compile because the reference to the dll was broken, so I deleted it and added it again, then the web page where the ReportViewer is used gave a parser error:

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).

I found a reference on the webpage with version number different to the one I had just added:

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

I changed the version to 9.0.0.0, and this time got a compiler error when I refreshed the page:

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'

I then searched the solution for "Microsoft.ReportViewer" and found more references in compilation.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>

I changed the version numbers here too and it stopped the errors



回答3:

You may also need to Remove from \bin files:

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

I just moved them into a sub directory.



回答4:

Check your page rdlc version like

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


回答5:

Having the same issue. Clean Windows 2008 Server install with SQL Server 2005 and SQL Reporting. The server hosts the site. Installed ReportViewer 2008 SP1. Web.config references version 9.0.0.0.

The same error message comes up: The base class includes the field but its type (Microsoft.Reporting.WebForms.ReportViewer) is not compatible with the type of control (Microsoft.Reporting.WebForms.ReportViewer).

Searched online and lots of people experience the same issue. Some people suggest manually editing project file. I managed to fix it by setting Specific Version = True (Version=9.0.0.0) in the Solution Explorer->[Web Project Name]->References->Microsoft.Reporting.WebForms->Properties.

In one of the environments we also found Microsoft.Reporting dlls in the web bin folder. And, they were conflicting with the dlls registered in the GAC. Deleting of the dlls solved the issue.



回答6:

I had this problem on a Production server. I installed the correct version of ReportViewer and made sure all the references in the project were pointing at the correct version. However, I was still getting errors.

Eventually I solved the problem by going to 'Temporary ASP.NET Files' and deleting the files for my app. To do this you'll need to stop the app first. This then solved the problem. On DEV servers I had not encountered this problem because after installing ReportViewer I re-started the machine.

Hope this helps someone. I pulled a lot of hair out before I solved this particular 'challenge'.



回答7:

References -> (Microsoft.ReportViewer.WebForms), click the right mouse button.

The Specify Version option, leave it as false.

After that, just save and run again.



回答8:

I came across the same error. What worked for me was to delete the reference Microsoft.ReportViewer.WebForms and add it again.