Alex Rivera | Logout

Global exception handler for windows services?

Asked 2009-11-05T17:13:05.953
29

Is there a way to globally handle exceptions for a Windows Service? Something similar to the following in Windows Forms applications:

Application.ThreadException += new ThreadExceptionEventHandler(new ThreadExceptionHandler().ApplicationThreadException);
Edit
Report

1 Answer

28

Have you tried

AppDomain.CurrentDomain.UnhandledException

This will fire for unhandled exceptions in the given domain no matter what thread they occur on. If your windows service uses multiple AppDomains you'll need to use this value for every domain but most don't.

answered 2009-11-05T17:15:14.617

Your Answer