Assuming you've got the settings configured ok, when you get the error is
the service process exe still running? I'm wondering if the executable is
still running even though the service part has failed somehow.
I suspect all this may have something to do with your OnStart. Connecting to
a web service is a time-consuming thing. OnStart IMO is for short lived
stuff. Windows has a timeout here. It's also not clear to me that you can
call ServiceController.Stop from in your OnStart either because the service
might not be marked as started until you return from OnStart. Plus if a
thread took an exception here you might be stuck with the process running
but the service pieces inactive.
I'd dump all that stuff from OnStart and defer it to a Thread running from
your ServiceMain, something like that.
--
Phil Wilson [MVP Windows Installer]
----
"Sergey Krutous" <Se***********@discussions.microsoft.com> wrote in message
news:F6**********************************@microsof t.com...
Can you please help me to resolve the following issue:
I developed a windows service. At start up (I have overriden OnStart
method) it connects to a web service and if the connection fails the
windows
service sets ExitCode property to non-zero value (55) and calls Stop
method.
If this happens when user starts the service in Services snap-in SCM shows
error massage and service stops - it's OK.
I configured automatic startup and Recovery settings for the service:
- set 'restart the service' for the first, second and subsequent failures,
- 'reset fail count after' 0 days,
- 'restart service after' 1 minute
but SCM does not attempt to restart the service at startup if error
happens.