cheziHoyzer
cheziHoyzer

Reputation: 5021

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

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: enter image description here

How can I do that?

Upvotes: 1

Views: 2861

Answers (1)

Sheridan
Sheridan

Reputation: 69959

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.

Upvotes: 4

Related Questions