Ojas Maru
Ojas Maru

Reputation: 459

The type 'Microsoft.Reporting.WebForms.ReportViewer' exists in both

I have a ASP.NET application which was referring Microsoft.ReportViewer.WebForms of version 9.0.0.0, I changed to refer to Microsoft.ReportViewer.WebForms of version 11.0.0.0. Now when I run my application on 2 of the machines I get following error

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0433: The type 'Microsoft.Reporting.WebForms.ReportViewer' exists in both 'c:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\9.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll' and 'c:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\11.0.0.0__89845dcd8080cc91\Microsoft.ReportViewer.WebForms.DLL'

I have ensured that everywhere in my web.config version number is updated to 11.0.0.0

Upvotes: 7

Views: 18435

Answers (2)

Pažout
Pažout

Reputation: 2161

My solution. I had old version of ReportViewer in _bin_deployableAssemblies folder. I deleted all from this, and use references from 'packages\Microsoft.ReportViewer.11.0.3366.16\lib' folder.

Upvotes: 0

Ojas Maru
Ojas Maru

Reputation: 459

I tried adding dependentAssembly in web.config but that did not help.

<dependentAssembly>
  <assemblyIdentity name="Microsoft.ReportViewer.WebForms" publicKeyToken="89845dcd8080cc91" />
  <bindingRedirect oldVersion="8.0.0.0-10.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>

However it did not help as PublicKeyToken has changed in 11.0.0.0 dll.

Finally I was able to resolve the issue by adding qualifyAssembly node in web.config

<qualifyAssembly partialName="Microsoft.ReportViewer.WebForms" fullName="Microsoft.ReportViewer.WebForms,version=11.0.0.0,culture=neutral,publicKeyToken=89845dcd8080cc91" />

Upvotes: 5

Related Questions