Sharepoint Services

An application that was developed by me as a service with Net Core 8 didn’t want to start working as a Windows service. The application was created in Visual studio 2022 with a “Worker service” template. If you just start the app, it works. But I had problems to start it as a Windows Service.

Windows could not start the RG.NetworkService service on Local Computer.
Error 1053: The service did not respond to the start or control request in a timely fashion.

If you checked, that you are administrator and other trivial things, it's time to fix your code. The solution for me was to add a specific feature for Windows service.

1. Add package Microsoft.Extensions.Hosting.WindowsServices with Nuget.

2. Add UseWindowsService() to IHost() object. It's necessary only if it detects the process is running as a Windows Service.

IHost host = Host.CreateDefaultBuilder(args)
   .UseWindowsService()
   .... 
  .Build();
await host.RunAsync();