ReportViewer error on debugging

10,445

Solution 1

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.

Solution 2

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.

Share:
10,445
John Wesley Gordon
Author by

John Wesley Gordon

Software Developer at Leidos. Owner of ZoneGordon.Com and Salted Chips Studios. Worked for 6 Months as a contractor for TekSystems, Worked for 14 years as a Systems Administrator and Developer for TimBar Packaging &amp; Display / Packaging Corporation of America. I work in multiple programming areas including ASP.NET, C#, Java, JavaScript, HTML, CSS, and SQL to name a few.

Updated on June 13, 2022

Comments

  • John Wesley Gordon
    John Wesley Gordon almost 2 years

    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>
    
  • Codes with Hammer
    Codes with Hammer almost 9 years
    I just had a similar case, having to change some instances of Version=9 to Version=10. I agree with the lesson learned.