ServiceController throws exception

  • Thread starter Thread starter Strider
  • Start date Start date
S

Strider

Hello.

I have created a Windows Service and now I'm trying to
develop a controller application for my service.

So, I created a Windows.Forms project, I added a
System.ServiceProcess.ServiceController component on my
form and I hooked it up to my service.

The start and stop commands work just fine, but when I
try to invoke a custom command on my service using the
ServiceController.ExecuteCommand method, I get the
following exception:

"System.InvalidOperationException: Cannot control
MyService service on computer '.'. --->
System.ComponentModel.Win32Exception: Access is denied\r\n

I guess it has something to do with the services security
settings or my code's access permissions.

Any clues?

Thanks in advance.
 
Got it!

The command ID parameter should be an integer value
between 128 and 256. Values less than 128 are reserved
by the operating system.

Funny how the .NET Framework class library documentation
doesn't mention this!
 
Back
Top