Getting System.ServiceProcess.ServiceController.ExecuteCommand(int) to work

  • Thread starter Thread starter Tom J
  • Start date Start date
T

Tom J

What do I have to do to get
System.ServiceProcess.ServiceController.ExecuteCommand(int) to work?

I have written a service that overrides OnCustomCommand to handle commands
sent to it.

If I have application code like:

----------------------------------------------------------
ServiceController sc = new ServiceController("MyService");

sc.Start(); // this works

...code that checks running state is here...

sc.ExecuteCommand(1); //throws the exception

---------------------------------------------------------

I get an exception of: Cannot control MyService service on computer "."

Are there specific things i have to do to the service to allow it to accept
commands other than the standard start, stop, etc?

Thanks in Advance....Tom J
 
User defined control codes must be =>128 and <= 255. The operating system
reserves numbers under 128.

Willy
 
Back
Top