none
WCF versus overloading the Windows Service ServiceBase.OnCustomCommand method RRS feed

  • Question

  • I will be building a new Windows Service soon and wish to communicate with it using something similar to the Management Studio used by SQL Server.  Currently .Net development allows communication by passing a number value of 128-256 using the ServiceController.ExecuteCommand method.  About half the time using just a number to cause code execution will work for me but the other half I generally would like to pass additional information to my Windows Service giving it specifics of what to do. 

    I see my current options as registry, too old school, text files, please kill me, writing to a database table or, my personal choice, adding a WCF Service to execute within my Windows Service and pass the additional parameters to it prior to calling ServiceBase.OnCustomCommand.

    Finally, to my question.....

    Why has MS chose to not overload the OnCustomCommand method to accept an object to I can pass a collection or any other type of object to it and use that object to determine specifics for what I want to actually do in my Windows Service based on the 128-256 number passed in?

    If there is a beter forum for this question please let me know.

    Friday, April 18, 2014 11:50 PM

Answers

  • Why has MS chose to not overload the OnCustomCommand method to accept an object to I can pass a collection or any other type of object to it and use that object to determine specifics for what I want to actually do in my Windows Service based on the 128-256 number passed in?

    The Windows Service is hosting the WCF service. The WCF client program is communicating with the WCF service directly, and the client program has no need to be communicating with the Windows service other than to tell it to shutdown.

    Why should MS and .NET extend the OnCustomCommand() of the Windows Service to go beyond its original intent of sending in a number, a custom command to the service? And when that number is passed into the Windows service via OnCustomCommand(), the service code acts upon the command. OnCustomCommand is a command, and it is not a means to be passing objects or primitive type parameters other than a single Int32. 

    It is what it is, and you need to take a different approach.

    Sunday, April 20, 2014 4:45 AM