从处理WPF中的WinForms组成部分未处理的异常 [英] Handling Unhandled Exceptions from Winforms components in WPF

查看:110
本文介绍了从处理WPF中的WinForms组成部分未处理的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序是建立在WPF,但它包含一些我们写的WinForms组件。当一个例外是在未处理的WinForms的组件崩溃的应用程序之一。

我已实施 DispatcherUnhandledException 为WPF事件。这是好事,因为它可以让我的处理,以避免崩溃显示错误并标记异常。

我可以做非WPF异常类似的东西。我希望的是用来上来,并允许用户继续还是蛮应用标准的WinForms对话框?

修改:WinForms的例外也陷入 DispatcherUnhandledException ,但设置e.Handled为true不会崩溃停止应用程序

解决方案

您是否尝试过<一个href="http://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception.aspx">System.Windows.Forms.Application.ThreadException和<一href="http://msdn.microsoft.com/en-us/library/system.windows.forms.application.setunhandledexceptionmode.aspx">System.Windows.Forms.Application.SetUnhandledExceptionMode ?

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.

解决方案

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

这篇关于从处理WPF中的WinForms组成部分未处理的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆