ceth
ceth

Reputation: 45295

Log all unhandled exceptions

Every time when an unhandled exception occurs the VS show me debugger on file App.g.i.cs:

#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
        UnhandledException += (sender, e) =>
        {
            if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
        };
#endif

As I know this file is automatically generated and I can not make any changes in it.

But I want to log all unhandled exceptions to the text file. Where is the best way to do it ?

Upvotes: 0

Views: 78

Answers (1)

Rob Caplan - MSFT
Rob Caplan - MSFT

Reputation: 21899

You can add your own UnhandledException handler in your App class (app.xaml.cs) and log from there. Note that not all exceptions can be handled, but this will catch the globally handleable ones.

See App-level exception handling for more information.

Upvotes: 2

Related Questions