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

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

问题描述

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



实现全局Try / Catch块的最佳位置在哪里。至少我必须实现一个消息框:对不起...

解决方案

你可以处理 AppDomain.UnhandledException 事件



编辑:实际上,这个事件可能更充分: Application.DispatcherUnhandledException


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

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 ..."

解决方案

You can handle the AppDomain.UnhandledException event

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

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

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