在使用PRISM时, 使用了Windows Form Host 加载了Report View11控件, 窗体关闭后, 在退出PRISM程序时, 系统抛出异常
Error while unloading AppDomain. (Exception from HRESULT: 0x80131015)
这是微软已知的一个BUG, 详情参见
http://connect.microsoft.com/VisualStudio/feedback/details/522208/wpf-app-with-reportviewer-gets-error-while-unloading-appdomain-exception-on-termination
解决方案相当简单:
在关闭ReportViewer调用的窗体之前执行 reportViewer.LocalReport.ReleaseSandboxAppDomain()
事件即可. 如:
private void frmMyForm_FormClosing(object sender, FormClosingEventArgs e)
{
reportViewer1.LocalReport.ReleaseSandboxAppDomain();
}
这样就不会有问题了.