Is there a way to write a Service so that it will fail? I'm working
on a Service written in VB.Net, that supports an application we are
building, and I want to make sure that it can restart itself. This
is my first experience with it. In the Service Control Manager I
know there are the options to say what to do if it fails, obviously I
want to select Restart the Service. But how to test it? I can kill
the Service there, but it does not restart. I presume Windows knows
that it was stopped on purpose, rather than failing. I also tried a
little app that called ServiceControll er.Stop() on the Service, and
that also did not work. Again I presume Windows saw that as a Stop
order, not a failure.
Someone suggested throwing an unhandled Exception, but I cant get that
to work. I tried putting in a thread that slept for a while and then
threw the Exception, but it seems to only exit the method and not
kill the Service. So then I put the Exception into the OnStart
method itself, and what happened was that when I started the Service
in the Service Control Manager, it immediately stopped and put up a
MessageBox saying the Service "started and then stopped. Some
services stop automatically if they have no work to do ..."
Also, I wonder if there is a property in the ServiceInstalle r where I
can tell it to set itself for those "Restart the Service" options. I
see how to set it to start Automatically, but I don't see the others
available.
Thanks
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com