Skip to content

Uncaught exception handlers

George George

Asked Apr 26, 2008, 6:52 AM EDT4 answers
Share
LinkedInX

Hello everyone,


I am new to how to catch uncaught exception. From some self-learning, I think we should use, event handler for AppDomain.CurrentDomain.UnhandledException other than Application.ThreadException if we are writing console or Windows service, right?

Application.ThreadException is for Windows Form application, not console and Windows Service application?


thanks in advance,
George

4 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Bechir Bejaoui
    0
    you should create your own exception by inheriting it from the Application exception and then throw it using the "throw new" statement
    0
  • 0

    Sorry, maybe I have not made myself understood. My question is how to be notified of uncaught exception?

     

    regards,

    George

    0
  • 0
    AppDomain.CurrentDomain.UnhandledException would work, I normally use it in the UI layer of my applications to catch any wild exceptions that I didnt expect.
    0
  • 0

    Thanks Brandon,

     

    Sorry I mean for non-UI program, like console application and Windows service application, we should use AppDomain.CurrentDomain.UnhandledException other than Application.ThreadException, right?

    (I think Application.ThreadException only works for Windows Forms application, not works for console and Windows Service application)

     

    regards,

    George

    0