Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReportViewer error on debugging

I am working on some code a previous developer built at my company trying to add a ReportViewer to an ASP.NET C# page. When I begin debugging I get the following.

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

I read some articles suggesting my reference might be old. I am referencing Microsoft.ReportViewer.WebForms 9.0.0.0.

I have a ReportViewer in a different page, same project, that is working. When I change my reference to WebForms 10.0.0.0 it breaks with a similar message. In order to get it working again I have to change back to 9.0.0.0 and put back my web.config from before I made this change.

To get all ReportViewers to work do I need to be on 9.0.0.0 or 10.0.0.0 and do I need to make changes to the web.config?

Here are the two report viewers. I don't see anything pertinent that is different with them.

Working today under 9.0.0.0 in page1.aspx

<rsweb:ReportViewer ID="ReportViewer1" runat="server" Height="515px" ProcessingMode="Remote" Width="100%" Visible="false">
    <ServerReport ReportServerUrl="http://servername/reportserver" />
</rsweb:ReportViewer>

Not working under 9.0.0.0 or 10.0.0.0 in page2.aspx

<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" 
    Font-Size="8pt" ProcessingMode="Remote" 
    WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
    <ServerReport ReportServerUrl="http://servername/reportserver" />       
</rsweb:ReportViewer>
like image 976
John Wesley Gordon Avatar asked Dec 20 '22 21:12

John Wesley Gordon


2 Answers

I had to change in page2.aspx the following line

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

to

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

I guess the lesson to be learned is keep all your versions the same number from the reference through the rest of your code including your web.config.

like image 80
John Wesley Gordon Avatar answered Dec 22 '22 09:12

John Wesley Gordon


The correct way when using MS report view controls is to install the Nuget package

https://www.nuget.org/packages/Microsoft.Report.Viewer

Install-Package Microsoft.Report.Viewer

This way, you will get the latest dlls in your solution and you will ensure that it will work when you deploy it on production server.

like image 30
Anas Ghanem Avatar answered Dec 22 '22 11:12

Anas Ghanem