How to add global exception handling to a add-in dll?

Posted by redjackwong on Stack Overflow See other posts from Stack Overflow or by redjackwong
Published on 2010-01-11T07:18:05Z Indexed on 2010/04/21 2:03 UTC
Read the original article Hit count: 418

Here's my context:

  • I am writing a WPF add-in for an application.
  • This Application's main thread is unmanaged.
  • I want to add a global exception handling system for this add-in to handle any unhandled exceptions.

Here's what I've tried but not working:

  • I cannot add a try-catch block to my Application.Run() code line. Because I am an add-in, that code fragment is in the application.
  • System.Windows.Forms.Application.ThreadException is not working too. There might not be an WinForm Application exists. (WPF hosting in unmanaged code.)
  • AppDomain.CurrentDomain.UnhandledException is not working too. Because maybe it's handled by the Application itself. It just doesn't enter my code.

So, any ideas for this situation?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about wpf-controls