The base class includes the field ‘ReportViewer1’ but its type is not compatible

In this article, we will learn how to solve The base class includes the field ‘ReportViewer1’ but its type is not compatible with the type of control “Microsoft.Reporting.WebForms.ReportViewer” that you may face when adding a new Microsoft.Reporting.WebForms.ReportViewer reference to your ASP.NET or SharePoint solution.


The base class includes the field ‘ReportViewer1’ but its type is not compatible

In ASP.NET and SharePoint Solution, I have tried to add a “Report Viewer” control to visual web part but, I got the below error:

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)

The base class includes the field 'ReportViewer1' but its type is not compatible

I have checked the references in the SharePoint Solution, I had noticed that The “Microsoft.Reporting.WebForms” reference is not added!

Using Microsoft.Reporting.WebForms in SharePoint

I added the “Microsoft.Reporting.WebForms” reference then I tried to deploy the SharePoint solution again. but I got a new error as shown below:

CS0433: The type ‘Microsoft.Reporting.WebForms.ReportViewer’ exists in both ‘c:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms \10.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.dl

The type 'Microsoft.Reporting.WebForms.ReportViewer' exists in both
The base class includes the field ‘ReportViewer1’ but its type is not compatible

The type ‘Microsoft.Reporting.WebForms.ReportViewer’ exists in both

Cause

This issue usually occurs in case of the Microsoft.Reporting.WebForms.ReportViewer reference version that attached to the SharePoint Solution is not matched with the reference version that already registered in the Web.config file of the SharePoint Web Application.

In my case, the SharePoint solution has the reference “Microsoft.ReportViewer.WebForms” version 10. Meanwhile, the Web.config of the SharePoint Web Application has the reference “Microsoft.ReportViewer.WebForms” Version 9.

Microsoft.Reporting.WebForms.ReportViewer reference

Solution

The solution for this issue is removing the old Microsoft.Reporting.WebForms.ReportViewer reference and add the new one as the following:

Steps
  1. Match the two version numbers in the SharePoint Solution & Web.Config,
  2. Register the reference in the web part as the following:
    • In SharePoint Solution, remove the “Microsoft.ReportViewer.WebForms” Version 10.
    • Add “Microsoft.ReportViewer.WebForms” reference Version 9.
    • Register the assembly tag in the front code of the visual web part.
Register Microsoft.ReportViewer.WebForms in SharePoint Solution

Conclusion

In conclusion, we have learned how to register Microsoft.ReportViewer.WebForms reference in a SharePoint solution to avoid the below mismatching issues:

  • The base class includes the field ‘ReportViewer1’ but its type is not compatible.
  • The type ‘Microsoft.Reporting.WebForms.ReportViewer’ exists in both.
Applies To
  • SharePoint 2016.
  • SharePoint 2013.
  • .Net Solution.
  • Report Viewer.
See Also

2 thoughts on “The base class includes the field ‘ReportViewer1’ but its type is not compatible”

Leave a Reply