Windows service starts and stops automatically

G

Guest

I have two window services that I created in C# and VB.net, one each, and set
them to manual startup type. However, sometimes (not everytime) when I starts
the service, an error message pops-up to say the service started and stopped
automatically.

-----------------------------------------------------------------------------------------------
The dicer service on Local Computer started and then stopped. Some services
stop automatically if they have no work to do, for example, the Performance
Logs and Alerts service.
-----------------------------------------------------------------------------------------------

Why is this so? What causes it? Anyhow I can solve this? I am running the
service on Windows XP.

thanks
Eugene
 
H

Howard Swope

I think this is probably indicative of an error occurring on start up. You
might try catching any errors in the startup routines and writing out an
error to an event log. It is tough to debug because the SCM is running the
process and you can't attach to it with the debugger until after startup.
 
M

mdb

I think this is probably indicative of an error occurring on start up.
You might try catching any errors in the startup routines and writing
out an error to an event log. It is tough to debug because the SCM is
running the process and you can't attach to it with the debugger until
after startup.

Not true... If you put a MessageBox in Main() or some other call that
will delay processing, you can attach to it just fine. Then you can set a
breakpoint in OnStart() or wherever you need.

(Of course, if you use MessageBox or anything else that involves UI, then
you need to run the service as LocalService with access to the desktop,
which ISN'T a good thing, but it will work for purposes of debugging.) A
call to Thread.Sleep would work just as well, as long as you give yourself
enough time to attach.
 

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