How to show a stack trace reports of unhandled exceptions in WPF

给你一囗甜甜゛ 提交于 2019-12-08 07:27:32

问题


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)
    {
        ...
    }

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

How can I do that?


回答1:


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;
}

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



来源:https://stackoverflow.com/questions/20492739/how-to-show-a-stack-trace-reports-of-unhandled-exceptions-in-wpf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!