Windows Service Crashing

  • Thread starter Thread starter Shawn Meyer
  • Start date Start date
S

Shawn Meyer

A windows service that I developed is crashing unexpectedly. All the
logging/ tracing that I implemented cannot seem to catch the crash. I am
using multiple threads in many different areas.

In the event log I am getting a 7034 error. "Service terminated
unexpectedly."

Here is the question?
What is the best way to implement a global exception handler so I can catch
what is going on?

Shawn
 
As a general catch all you could use:
AppDomain.CurrentDomain.UnhandledException +=new
UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

Althought not relevant to Services, for Windows apps I use this:
Application.ThreadException += new
ThreadExceptionEventHandler(OnThreadException);

But I only enable them in production builds.
 
I ask because the first thing that comes to my mind
is that a call to Win32 with improper arguments is
more likely to cause a crash in your service.
Maybe you should narrow your investigations on
what is causing the crash to calls to Win32 and
try to "comment" them or replace them with calls
to .NET API...
 
Back
Top