views:

239

answers:

0

Possible Duplicate:
WPF global exception handler

Hello SO, since "good old" WinForms days, I have been writing client code similar to

static void Main (string[] args)
{
    AppDomain.CurrentDomain.UnhandledException += 
        CurrentDomain_UnhandledException;
    System.Windows.Forms.Application.ThreadException += 
        Application_ThreadException;

    // actual application ;)
}

private static void Application_ThreadException (
    object sender, 
    ThreadExceptionEventArgs e)
{
    // log error and terminate application ...
}

private static void CurrentDomain_UnhandledException (
    object sender, 
    UnhandledExceptionEventArgs e)
{
    // log error and terminate application ...
}

I have since graduated to WPF, and am curious about WPF mechanisms for error handling\reporting. Specifically,

  • will an unhandled error on a WPF Gui thread still raise the Application.ThreadException event?
  • is there a WPF analog to Application.ThreadException?
  • is AppDomain.UnhandledException sufficient for all unhandled exceptions raised within a WPF application?

EDIT: sorry guys, just found this, closing question. oh, to summarize

  • WPF analog to System.Windows.Forms.Application.ThreadException is System.Windows.Application.DispatcherUnhandledException [it is an instance member, so reference Application.Current to find it!]

Now I can leave System.Windows.Forms for good! w00t!