NetCore 2.1 Generic Host as a service

前端 未结 3 1071
北恋
北恋 2021-02-08 18:07

I\'m trying to build a Windows Service using the latest Dotnet Core 2.1 runtime. I\'m NOT hosting any aspnet, I do not want or need it to respond to http requests.

I\

3条回答
  •  囚心锁ツ
    2021-02-08 19:09

    IHostedService if for [asp.net core] backendjob, if u want to build a windows service on .net core, u should reference this package System.ServiceProcess.ServiceController, and use ServiceBase as base class. (you can also start from a .net framework windows service and then change the .csproj file)


    edit: please see this doc and this code https://github.com/aspnet/Hosting/blob/dev/src/Microsoft.AspNetCore.Hosting.WindowsServices/WebHostWindowsServiceExtensions.cs. To create a windows service ServiceBase for manage your IHost

提交回复
热议问题