Windows Service Terminated Unexpectedly

  • Thread starter Thread starter Graham Siener
  • Start date Start date
G

Graham Siener

Hi All,

I have a real confusion situation on my hands. I've written a windows
service in c# that basically does archiving of data from one database
to another. Along the way it parses one field which is a large xml
document into many children fields. This service uses COM+ components
also written in c#, but the service is triggered by a windows event.

My problem is this: The service works fine when archiving a small
number of items (< 100) but I've been running "destructive tests" on
this service to see what it can handle, and when I'm archiving a large
number of items ( ~ 1000) the service will unexpectedly terminate. No
exceptions, no errors in the event log other than that the service
unexpectedly terminated.

Apparently Dr. Watson was running and "he" always gets a dump when the
service crashes. The causing function call is always
kernel32!lstrcmpiW (which I am not calling directly ever!). Any ideas
on what's going on? I've tried hammering the individual pieces and
that seems to work.

What's interesting is I took the archiving code loop and put it in a
winforms app. When I run the loop directly from that app, it also
crashes!

How is this happening in .NET land? How can I possibly catch these
errors?

I actually attached to this process and watched for the Exited event.
The error codes I got from two times were -2147483645 and -532459699,
both of which seem like gibberish.

Please let me know if you have any advice/suggestions/anecdotes -- I
would love to figure this one out.

Thanks!
 
Graham Siener said:
What's interesting is I took the archiving code loop and put it in a
winforms app. When I run the loop directly from that app, it also
crashes!

Ok, it's nothing to do with the service then.
How is this happening in .NET land? How can I possibly catch these
errors?

Find the line of code that is causing the error maybe by stepping through
the code or logging to a file. Then see if the same line of code on it's own
causes the error. Then work out how to avoid the error.

As an example I had a similar situation if a user entered the sqlserver name
as MyServer:PortNumber or \\MyServer:PortNumber so I just had to add checks
to make sure they didn't enter it in those formats.

Michael
 
Are you getting an OutOfMemoryException in the WinForms app? What is the exception being thrown?
 
Thanks for the prompt replies everyone. Unfortunately I am not getting
any exceptions at all, that is the problem...

As for the line of code, there isn't one line that is consistently
causing the problems. And, I am going to try debugging, but this issue
is not consistent. Sometimes I can get through 1000+ items before the
crash happens, and I would rather not step through the code 1000+ times
hoping to find the one that will do it.
 
I see, without exceptions (or consistency) it definately makes are programming lives more difficult ;)

I suggest adding some EventLogging into the code. It will help to identify where the crash is occuring.

A better suggestion is to open VS.NET, go to Debug --> Exceptions, and select Break All for the top-level node. This will break
into the debugger when the first exception occurs. That should help a bit :)
 
Back
Top