如何使C#应用程序充当服务?

Pet*_*ter 4 .net c# windows

我开发了一个C#程序,虽然当我尝试从中创建一个服务时,例如

sc create "servicetest" binPath= 
   "C:\Users\Admin\Desktop\test\test.exe" start= auto error= ignore
Run Code Online (Sandbox Code Playgroud)

我收到以下消息:

[SC] StartService FAILED 1053:

The service did not respond to the start or control request in a timely fashion.
Run Code Online (Sandbox Code Playgroud)

Sna*_*ake 7

您需要通过Visual Studio界面将其创建为服务,该界面将为您提供需要实现的正确类和方法.