Windows Service in DotNet Core 2.1+ RRS feed

  • Question

  • I have to execute some code in the backgroud that will watch some database tables and execute some logic. In dotnet framework, i implemented it through windows service.

    Now i have similar requirement in dotnet core because code can be deployable to any OS like Linux. I have few queries because i didn't get any clear answer over internet.

    1) I didn't find any template for Windows Service so is it possible to implement windows service in dotnet core 2.1+?

    2) If dotnet core supports windows service implementation, can anyone help to implement the same?

    3) If dotnet core supports windows service implementation, does it deployable to linux machine too?

    Monday, January 7, 2019 12:28 PM


  • Windows services are a Windows only feature. They aren't supported on other platforms although other platforms may support an equivalent technology. 

    1) ServiceBase is documented as being in .NET Core 2.1+ and is discussed here. It appears that it is partially working but things like installation don't work. There is currently no support for non-Windows systems but you can refer to the GitHub issues to track its progress.

    2) There are some blog articles on how to get a "service" running on .NET Core. Some of the recent updates to .NET Core to get the rest of the framework on board may simplify this.

    3) No. I suspect you'll get a runtime error.

    Personally I would recommend that you migrate your non-service code to .NET Standard and then leave your service class in NF for now. In my experience the (service) host is just that. The core functionality is in the library part of your app (which can be .NET Standard) and just the service class host is in NF.

    Michael Taylor http://www.michaeltaylorp3.net

    Monday, January 7, 2019 4:34 PM