[quoted text, click to view] Scott in Tempe wrote:
> I am trying to debug an access violation when stopping a service.
> I have run the service in the debugger as defined in
>
http://support.microsoft.com/?kbid=170738 but it terminates the debugger soon
> after the debugger breaks on the access violation. I would like to have time
> to debug the problem before the SCM terminates the process.
>
> How do I stop the SCM from terminating the process 20 seconds after it tells
> the service to stop?
>
> Thanks,
> Scott
Scott -
Boy, this is a new one on me. I was under the impression, and my
experience has been the SCM would send a STOP to the service, but I have
never seen it kill the process before. I wonder if perhaps this is a new
behaviour from a later release OS than I am developing under (W2K)? I
was thinking the process kill would not happen unless responding to
SHUTDOWN. Perhaps debugging under W2K would be a possibility if this is
true.
Under .NET, unfortunately you can not easily HINT the stopping time, as
you can when directly interfacing to the SCM, as we did before .NET. One
thing you MAY be able to do is to have your service handler defer the
actual stopping logic to a thread, and return immediately from your STOP
handler. Don't break before the STOP handler returns! I believe this
will tell the SCM you have stopped, and then with your breakpoint set in
the thread processing, and exception trapping enabled, you may have
enough time to debug. You may need a Thread.Sleep in your STOP thread to
allow the STOP handler to exit first.
I would be very interested in knowing what you find works for you, if
anything.