Weird behaviour when I open a reportviewer in WPF

爷,独闯天下 提交于 2019-12-12 03:11:46

问题


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 ?


回答1:


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



来源:https://stackoverflow.com/questions/7208482/weird-behaviour-when-i-open-a-reportviewer-in-wpf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!