IHost host = Host.CreateDefaultBuilder(args) .UseWindowsService() .ConfigureLogging(loggerfactory => loggerfactory.AddEventLog()) .ConfigureServices((hostContext, services) => { IConfiguration configuration = hostContext.Configuration; services.AddHostedService(); services.ConfigurePgSqlContext(configuration); services.AddSingleton(); services.AddScoped(); }) .Build(); await host.RunAsync();