diff --git a/aspnetcore/hosting/windows-service/sample/Program.cs b/aspnetcore/hosting/windows-service/sample/Program.cs index 0c9b26872a68..759880b0d059 100644 --- a/aspnetcore/hosting/windows-service/sample/Program.cs +++ b/aspnetcore/hosting/windows-service/sample/Program.cs @@ -16,14 +16,11 @@ public static void Main(string[] args) var pathToExe = Process.GetCurrentProcess().MainModule.FileName; var pathToContentRoot = Path.GetDirectoryName(pathToExe); - var host = new WebHostBuilder() - .UseKestrel() - .UseContentRoot(pathToContentRoot) - .UseIISIntegration() - .UseStartup() - .UseApplicationInsights() - .Build(); - + var host = WebHost.CreateDefaultBuilder(args) + .UseContentRoot(pathToContentRoot) + .UseStartup() + .UseApplicationInsights() + .Build(); host.RunAsService(); } #endregion @@ -45,13 +42,11 @@ public static void Main(string[] args) pathToContentRoot = Path.GetDirectoryName(pathToExe); } - var host = new WebHostBuilder() - .UseKestrel() - .UseContentRoot(pathToContentRoot) - .UseIISIntegration() - .UseStartup() - .UseApplicationInsights() - .Build(); + var host = WebHost.CreateDefaultBuilder(args) + .UseContentRoot(pathToContentRoot) + .UseStartup() + .UseApplicationInsights() + .Build(); if (isService) {