none
Handling Unhandled Exception in Window service RRS feed

  • Question

  • I have made a Window service and deployed successfully. But somhow it received an unhandled exception. My query is , how can i handle these unhandled expception . In a WinForm application i used 

    AppDomain currentDomain = AppDomain.CurrentDomain;

    currentDomain.UnhandledException += new UnhandledExceptionEventHandler(currentDomain_UnhandledException);

    but how can i get this functionality in Window service. As you must be aware that Window service has multiple threads running . My aim is to log any exception thrown . No exception should close my service without getting logged .


    Would be really thankful for help.

    Wednesday, February 11, 2009 8:36 AM

Answers

  • That's available in a service too.  The CLR can't catch exceptions that are raised on threads started by unmanaged code.  You'll need a debugger to see those.


    Hans Passant.
    Wednesday, February 11, 2009 11:22 AM
    Moderator