ReportViewer doesn't show embedded images: Unable to cast 'ReportHierarchy' to 'ReportHierarchy' RRS feed

  • Question

  •  Hi there!

    Whenever a ReportViewer on my pages tries to access an embedded resource it fails with:

    Unable to cast object of type 'Microsoft.Reporting.WebForms.ReportHierarchy' to type 'Microsoft.Reporting.WebForms.ReportHierarchy'.

    The ReportViewer's version is 9.0.30729.1 (ReportViewer 2008 SP1), SSRS is 2005.

    Stack trace:

    [InvalidCastException: Unable to cast object of type 'Microsoft.Reporting.WebForms.ReportHierarchy' to type 'Microsoft.Reporting.WebForms.ReportHierarchy'.] Microsoft.Reporting.WebForms.ReportDataOperation..ctor() +328 Microsoft.Reporting.WebForms.HttpHandler.GetHandler() +249 Microsoft.Reporting.WebForms.HttpHandler.ProcessRequest(HttpContext context) +13 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75 

    Is there anything I could do about it?

    Thanks and best regards,
    Wednesday, November 5, 2008 9:33 AM


  • An error stating that it can't convert the ReportHierarchy type to a ReportHierarchy suggests to me that there are actually two different versions of Microsoft.ReportViewer.Webforms.dll loaded.  You should be able to verify that by attaching to your web server with a debugger.  The object being retrieved by the report viewer http handler (and failing the cast) was placed there by the viewer executing on the ASPX page.  Some things I would look at:

    1. Are the report viewer assemblies in the GAC?
    2. Does the version of the assembly referenced in your web.config match the version in the GAC?
    3. Does the version of the http handler referenced in the web.config file match?
    4. Does your ASPX page declaratively reference the report viewer (using a <%@ Register tag) and if so, does that version match the ones in the web.config file?
    • Marked as answer by tvoigt Wednesday, March 30, 2011 8:51 AM
    Wednesday, November 5, 2008 2:25 PM