ServiceController.ExecuteCommand in C# can be used to send custom command to a windows service. Like here - How to send a custom command to a .NET windows Service from .NET code?
ServiceController myService = new ServiceController("MyService");
myService.ExecuteCommand(200);
I also understand that the command number should be between 128 and 256.
So I tried doing the same with both the service name and service display name, but crashed the windows service both times. It doesn't get caught in try catch.
And EventViewer says - "The MyService service terminated unexpectedly. It has done this 1 time(s)."
So my question is - Is it possible for a windows service to call ExecuteCommand within itself to invoke a call to OnCustomCommand() in the same windowsservice?
Thanks-