I have enabled exception handling, but I would like to configure a global handler to detect unhandled exceptions in the windows service
You could use AppDomain.UnhandledException. However, in your case, your entire call to your service can be wrapped in a try / catch block. Since you did not provide details about what you plan to do with this unhandled exception, your correct path, I think, in this case should resolve the service to fail .
try
{
MainCallToYourService();
}
catch (Exception)
{
//it probably too late to do anything useful here, try to log and die
}
Keep in mind that the problem is that in many cases your application state is corrupted by the time this event occurs. It’s best to try registering and logging out.
source
share