In some circumstances my .Net windows service can generate a StackOverflowException. Unfortunately, the behaviour seems to be that the service simply stops dead and doesn't write anything into the event log. I don't even get a message from the service control manager saying the service has failed.
is there any way at all a windows service can detect that such an exception has occurred?
In the documentation for this exception, MSDN says "Note that an application that hosts the common language runtime (CLR) can specify that the CLR unload the application domain where the stack overflow exception occurs and let the corresponding process continue". this is the kind of thing I would expect the windows service implementation to do, but it doesn't.
Please don't just reply saying I should make sure my code never ever throws such an exception - trust me, I would if I could - what I am trying to do is handle the worst case scenario in a sensible way and make my service resilient to unexpected errors.