From 11e0d3659270b58584c6d000085c47927451f7c9 Mon Sep 17 00:00:00 2001 From: ta264 Date: Thu, 4 Feb 2021 21:22:34 +0000 Subject: [PATCH] Fixed: Restart button restarts Lidarr correctly --- .../EnvironmentInfo/RuntimeInfo.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/NzbDrone.Common/EnvironmentInfo/RuntimeInfo.cs b/src/NzbDrone.Common/EnvironmentInfo/RuntimeInfo.cs index 6664ef0e9..e85fb27a9 100644 --- a/src/NzbDrone.Common/EnvironmentInfo/RuntimeInfo.cs +++ b/src/NzbDrone.Common/EnvironmentInfo/RuntimeInfo.cs @@ -27,14 +27,22 @@ namespace NzbDrone.Common.EnvironmentInfo serviceProvider.ServiceExist(ServiceProvider.SERVICE_NAME) && serviceProvider.GetStatus(ServiceProvider.SERVICE_NAME) == ServiceControllerStatus.StartPending; - //Guarded to avoid issues when running in a non-managed process - var entry = Assembly.GetEntryAssembly(); +#if NETCOREAPP + // net5.0 will return Lidarr.dll for entry assembly, we need the actual + // executable name (Lidarr on linux). On mono this will return the location of + // the mono executable itself, which is not what we want. + var entry = Process.GetCurrentProcess().MainModule; if (entry != null) { - ExecutingApplication = entry.Location; - IsWindowsTray = OsInfo.IsWindows && entry.ManifestModule.Name == $"{ProcessProvider.LIDARR_PROCESS_NAME}.exe"; + ExecutingApplication = entry.FileName; + IsWindowsTray = OsInfo.IsWindows && entry.ModuleName == $"{ProcessProvider.LIDARR_PROCESS_NAME}.exe"; } +#else + // On mono we need to get the location of the Lidarr assembly, not Mono. + // Can't be running tray app in mono. + ExecutingApplication = Assembly.GetEntryAssembly()?.Location; +#endif } static RuntimeInfo()