Search code examples
.netwpfreportviewer

Weird behaviour when I open a reportviewer in WPF


When I open a report in my WPF project once, I get this message this message when I exit

{"Error while unloading appdomain. (Exception from HRESULT: 0x80131015)"}

Stack Trace :

at System.AppDomain.Unload(AppDomain domain)
at Microsoft.ReportingServices.RefCountedAppDomain.Dispose()
at Microsoft.Reporting.WinForms.LocalReport.ReportRuntimeSetupHandler.ReleaseSandboxAppDomain()


at Microsoft.Reporting.WinForms.LocalReport.Dispose()
at Microsoft.Reporting.WinForms.ReportInfo.Dispose()
at Microsoft.Reporting.WinForms.ReportHierarchy.Clear()
at Microsoft.Reporting.WinForms.ReportViewer.Dispose(Boolean disposing)
at System.ComponentModel.Component.Finalize()

Is there something I do wrong ? I just open a form with a windowsFormHost and a ReportViewer inside. Do I need to close something else before closing my application ?


Solution

  • This is reported microsoft bug. However, there is a workaround for it - The workaround is to call

    reportViewer.LocalReport.ReleaseSandboxAppDomain();
    

    method before closing the parent form.

    example :

    private void frmMyForm_FormClosing(object sender, FormClosingEventArgs e)
    {
                reportViewer1.LocalReport.ReleaseSandboxAppDomain();
    
    }
    

    You can look at here for any assitance : http://connect.microsoft.com/VisualStudio/feedback/details/522208/wpf-app-with-reportviewer-gets-error-while-unloading-appdomain-exception-on-termination