From dc2ec781f00dd57c6aab40095ca314e21e5e08b3 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Mon, 6 Dec 2021 13:33:01 -0600 Subject: [PATCH] App does not Run as a service in a Windows Container Removing SessionId check in IsWindowsService(). This check is not correct when the process is being run in a Windows container. The container will get a different SessionId. Fix #52416 --- .../src/WindowsServiceHelpers.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceHelpers.cs b/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceHelpers.cs index 30dfb7c0135e38..7569a921263495 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceHelpers.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceHelpers.cs @@ -29,7 +29,7 @@ public static bool IsWindowsService() { return false; } - return parent.SessionId == 0 && string.Equals("services", parent.ProcessName, StringComparison.OrdinalIgnoreCase); + return string.Equals("services", parent.ProcessName, StringComparison.OrdinalIgnoreCase); } } }