如何在WPF中显示未处理的异常的堆栈跟踪报告 [英] How to show a stack trace reports of unhandled exceptions in WPF

查看:203
本文介绍了如何在WPF中显示未处理的异常的堆栈跟踪报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此EventHandler来捕获所有未处理的异常。

I using this EventHandler to catch all unhandled exceptions.

 public App()
        : base()
    {
        this.Dispatcher.UnhandledException += OnDispatcherUnhandledException;
    }

  void OnDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
    {
        ...
    }

我想显示exeption的堆栈跟踪(错误消息除外),如下图所示:
< img src =https://i.stack.imgur.com/tl2tk.pngalt =在这里输入图像描述>

I want to show the stack trace of the exeption (except the error message) like in this picture:

我该怎么做?

推荐答案

我可能没有理解这个问题,因为我的理解,这似乎是一个很简单的问题。在 Exception 类中有一个 StackTrace 属性。您可以从该属性获取堆栈跟踪:

I might not have understood this question because to my understanding, it seems to be quite a simple question. There is a StackTrace property on the Exception class. You can get the stack trace from that property:

private void OnDispatcherUnhandledException(object sender, 
System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
    string stackTrace = e.Exception.StackTrace;
}

您可以从 异常 class 页面。如果我误解了你的问题,请让我知道。

You can find out more from the Exception class page on MSDN. Please let me know if I have misunderstood your problem.

这篇关于如何在WPF中显示未处理的异常的堆栈跟踪报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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