How to make a C # application act as a service?

I developed a program in C #, although when I try to create it from it, for example,

sc create "servicetest" binPath= "C:\Users\Admin\Desktop\test\test.exe" start= auto error= ignore 

I get the following message:

 [SC] StartService FAILED 1053: The service did not respond to the start or control request in a timely fashion. 
+4
source share
3 answers

You need to create it as a service through the Visual Studio interface, which will provide you with the correct classes and methods that you need to implement.

+7
source

You need to create the application on the Windows service template available in Visual Studio (not available in the standard version). See here:

How to create windows services

+2
source

There is also another way to implement a Windows service using TopShelf . In fact, you can run the console application as a Windows service using topshelf. Its advantage is easy to debug. As far as I know, when you want to debug a Windows service, you start the service in the service console. Stop the service if you directly compile and install the service from the assembly. This is an additional painful step.

If you use topshelf, you can start a service, for example, how to start a Windows forms application for debugging. There are other benefits. Please refer to the website.

0
source

All Articles