My service sometimes fails. It’s not bad, and on windows 7 and windows server 2003, service restarts. But on windows XP I see message “WindowsService.exe has encountered a problem and needs to close. We are sorry for the inconvenience.” I added my service to the list of applications that are to be excluded from error reporting. It did not help – message showing without “Send report” and “Don’t send”.
The main problem in the fact that there is not unhandled exeption in my service. There is error in one dll (with unmanaged cod) and I can’t correct it.
How can I set my service so, that is work without this massages?
Added:
All my code in a try / catch block. Event log is “Faulting application WindowsService.exe, version 1.0.0.0, faulting module .dll, fault address 0x00010616.”
My service sometimes fails. It’s not bad, and on windows 7 and windows server
Share
Trying to catch this exception is a Bad Idea, an access violation is quite a nasty one. Subscribe to the AppDomain.CurrentDomain.UnhandledException event in your Main() method. In your event handler call Environment.Exit(1). This is not guaranteed to run, the unmanaged code might have started its own thread. The garlic cross you need for that one is SetUnhandledExceptionFilter(), you should write this in C++/CLI.