Windows Service Crashing

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
 
J

Jason Hales

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.
 
O

olrt

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top