This post originated from an RSS feed registered with .NET Buzz
by Doug Thews.
Original Post: Executing Commands Against a Windows Service
Feed Title: IlluminatiLand
Feed URL: http://apps5.oingo.com/apps/domainpark/domainpark.cgi?client=netw8744&s=JETBRAINS.COM
Feed Description: A technology blog for people enlightened enough to think for themselves
I've seen a lot of questions regarding problems trying to execute a custom command against a Windows Service. This assumes that you've already implemented an OnCustomCommand procedure inside your .NET code for the service and you're running it with valid permissions.
One of the most common errors when executing the code:
myServiceController.ExecuteCommand(iCode)
Is that you get an exception back that says:
"Cannot control service xxx on machine 'machine_name'"
Well, there's a single sentence of documentation on MSDN that explains the probable cause. It says that custom commands MUST be in the range of 128-255. Numbers under 128 are reserved for system-reserved values. It doesn't say anything about what numbers above 255 are used for.
So, for those of you having trouble sending custom commands to your Windows Service, try changing the command numbers to this valid range and it should fix your problem.