2
votes

I am building an asp.net C# application which uses buttons to retrieve and display RDLC reports within a View. The reports load without issue on localhost but when placed on Windows Server 2012 R2 Standard 64-bit and served through IIS version 8.5 the error:

[A]Microsoft.Reporting.WebForms.ReportHierarchy cannot be cast to [B]Microsoft.Reporting.WebForms.ReportHierarchy. Type A originates from 'Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' in the context 'Default' at location 'C:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\12.0.0.0__89845dcd8080cc91\Microsoft.ReportViewer.WebForms.dll'. Type B originates from 'Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' in the context 'Default' at location 'C:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\11.0.0.0__89845dcd8080cc91\Microsoft.ReportViewer.WebForms.dll'.

Is given when the report loads. This is preventing the embedded jpg image from loading in the report.

I am using Microsoft.ReportViewer.WebForms, Version=12.0.0.0 with no reference to version 11 in the web.config, .csproj or in the default.aspx. I have trolled msdn.microsoft.com, stackoverflow, google and youtube... to no avail.

What could be causing this error and is there a fix for it?

1

1 Answers

0
votes

Check your GAC on your deployment machine (or other locations in the path). There may be another version of the dll hiding on the server. In fact, rereading your error, I see the path to the GAC right there in the error, so that is what's happening.

I recommend setting "specific version" to true in your project where you reference the dll to ensure that the same version is used on your local and remote machines