The reason that the UnhandledException event on the current AppDomain does not fire is how services are executed.
- User sends a Start command from the Windows Service Control Manager (SCM).
- The command is received by the framework’s
ServiceBaseimplementation and dispatched to theOnStartmethod. - The
OnStartmethod is called.
Any exception which is thrown by OnStart is handled in the base class, logged to the Event Log, and translated into an error status code returned to the SCM. So the exception never propagates to the AppDomain’s unhandled exception handler.
I think you would find that an unhandled exception thrown from a worker thread in your service would be caught by the AppDomain’s unhandled exception handler.