捕获程序的每个异常? [英] Catch every exception of program?

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

问题描述

我有一个WPF应用程序,可以在全球范围内正常运行.但是有时候,客户告诉我他遇到了一些崩溃.但是除了他所做的之外,我没有发生任何事情的信息.

I've a WPF application which runs globally fine. But sometimes, the client tell me that he gots some crashes. But I've no information about what happened except what he does.

有没有办法放置全局try {} catch(Exception){LOGEXCEPTION;抛出;}接收某个GUI操作或任何其他选项生成的所有异常的地方.

Is there a way to put a global try{}catch(Exception){LOGEXCEPTION; throw;} somewhere to receive all exceptions generated by a GUI action, or any other option.

类似最后的补救措施"的日志会记录我们管理不善的异常情况?

Something like a "Last remedy" to log exception that we didn't manage well?

谢谢!

推荐答案

通过处理以下事件,您应该能够捕获应用程序中绝大多数(如果不是全部)未处理的异常:

By handling the following events, you should be able to catch the vast majority (if not all) unhandled exceptions in your application:

  • Application.DispatcherUnhandledException
  • AppDomain.CurrentDomain.UnhandledException
  • Application.DispatcherUnhandledException
  • AppDomain.CurrentDomain.UnhandledException

这篇关于捕获程序的每个异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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