Topshelf vs sc.exe vs Windows Service Project Type

As in the title, I would like to ask what is the difference between using these features to host my code in Windows Service. As far as I can tell, all three let me create an exe that will be installed as a service.

+6
source share
2 answers

Topshelf is my preference, because it allows you to get the best of both worlds, both the service and the console application. Using sc.exe allows you to run any console application as a service, but exe does not interact as a service itself. Developing Windows services directly allows you to have a service and interact as one with Windows, but it is not easy to debug or run as a regular console application. Topshelf allows you to work best as a service and work as a regular console application.

+11
source

Windows services are special types of applications that respond to service control messages, such as Start, Stop, Pause, Continue, etc.

Although it is true that you can use something like sc.exe to turn any process into a service, these processes will not process the previously mentioned control messages. What you usually find is that you can start the process but not stop it, etc.

What I usually do is to distract my services (I think Topshelf does this), have a service library that can be loaded with a native Windows Service application or a console application so that I can have the best of both worlds (usually debugging under console).

+2
source

All Articles