The base class includes the field ‘XXX’, but its type is not compatible with the type of control “Microsoft.Reporting.WebForms.ReportViewer”

In this article, I will solve the below issue

The base class includes the field ‘XXX’, but its type is not compatible with the type of control “Microsoft.Reporting.WebForms.ReportViewer”


Scenario

In 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 ‘rv_emp’, but its type (Microsoft.Reporting.WebForms.ReportViewer) is not compatible with the type of control (Microsoft.Reporting.WebForms.ReportViewer)

type is not compatible with the type of control

I have checked the references in the SharePoint Solution, I 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. unfortunately,  I got a new error 😦

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


Cause

This issue usually occurs in case of 

  • The reference version that attached to the SharePoint Solution is not matched with the reference version that already registered in the Web.config 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.


Solution

To overcome this issue, you should

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

Register Microsoft.ReportViewer.WebForms in SharePoint Solution


Applies To
  • SharePoint 2013.
  • SharePoint 2010.
Advertisements

One thought on “The base class includes the field ‘XXX’, but its type is not compatible with the type of control “Microsoft.Reporting.WebForms.ReportViewer”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s