4

I'm porting an application from .NET Framework 4.8 to .NET 5.0. Is there there a way to bring the functionality of System.ServiceProcess.ServiceBase to .NET 5.0? Are there any alternatives that could replace ServiceBase? Any workarounds?

Magic Mic
  • 43
  • 1
  • 3
  • 1
    Does this answer your question? [How to make a Windows service from .Net Core 3](https://stackoverflow.com/questions/56638847/how-to-make-a-windows-service-from-net-core-3) – Hans Passant Dec 04 '20 at 12:40

1 Answers1

11

ServiceBase is available in the NuGet package System.ServiceProcess.ServiceController. Visual Studio should suggest to install that package if you press Ctrl+. while the cursor is on the ServiceBase class name in the code editor.

If you create a new service you should think about switching to worker services (it has its own project template), see here. To run those worker services as a Windows service you'd then use the Microsoft.Extensions.Hosting.WindowsServices package. (That package also uses ServiceBase internally.)

cremor
  • 6,669
  • 1
  • 29
  • 72