Handling Unhandled Exceptions from Winforms components in WPF

∥☆過路亽.° 提交于 2019-12-30 03:18:20

问题


My application is built in WPF but it includes some WinForms components that we have written. When an exception is unhandled in one of the WinForms components it crashes the application.

I have implemented DispatcherUnhandledException for WPF events. This is good because it allows me to display an error and mark the exception as Handled to avoid the crash.

Can I do something similar with the non-WPF exceptions. I was hoping for the standard WinForms dialog that used to come up and allow the user to continue or quite the application?

Edit: WinForms exceptions do get caught in DispatcherUnhandledException but setting e.Handled to true doesn't stop the application from crashing.


回答1:


Have you tried System.Windows.Forms.Application.ThreadException and System.Windows.Forms.Application.SetUnhandledExceptionMode ?



来源:https://stackoverflow.com/questions/8111334/handling-unhandled-exceptions-from-winforms-components-in-wpf

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