WPF 全局异常处理程序 [英] WPF global exception handler

查看:30
本文介绍了WPF 全局异常处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时,在不可重现的情况下,我的 WPF 应用程序崩溃而没有任何消息.应用程序会立即关闭.

Sometimes, under not reproducible circumstances, my WPF application crashes without any message. The application simply close instantly.

哪里是实现全局 Try/Catch 块的最佳位置.至少我必须实现一个消息框:抱歉给您带来不便......"

Where is the best place to implement the global Try/Catch block. At least I have to implement a messagebox with: "Sorry for the inconvenience ..."

推荐答案

您可以处理AppDomain.UnhandledException 事件

You can handle the AppDomain.UnhandledException event

实际上,这个事件可能更合适:Application.DispatcherUnhandledException

actually, this event is probably more adequate: Application.DispatcherUnhandledException

这篇关于WPF 全局异常处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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