Currently I\'m checking it in the following way:
if (Environment.UserInteractive) Application.Run(new ServiceControllerForm(service)); else ServiceBase.R
Also, it must be noted, that Environment.UserInteractive always returns true in .NET Core, even if it is running as a Windows Service.
Environment.UserInteractive
true
For the time being, best method seems to be this one from ASP.NET Core.
Sources: .NET Core 2.2 .NET Core 3.1