From f7dc5cbb9b7a598236148af30b50d675d85c32c2 Mon Sep 17 00:00:00 2001 From: HavenDV Date: Wed, 10 Jul 2024 06:52:05 +0400 Subject: [PATCH] fix: Fixed assembly.Location issue for single file exe. --- src/libs/H.NotifyIcon/Core/TrayIcon.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libs/H.NotifyIcon/Core/TrayIcon.cs b/src/libs/H.NotifyIcon/Core/TrayIcon.cs index aa3cb44..fbcbdd9 100644 --- a/src/libs/H.NotifyIcon/Core/TrayIcon.cs +++ b/src/libs/H.NotifyIcon/Core/TrayIcon.cs @@ -239,7 +239,15 @@ public static string GetProcessPath() Assembly.GetEntryAssembly() ?? throw new InvalidOperationException("Entry assembly is not found."); - return assembly.Location; +#pragma warning disable IL3000 + var location = assembly.Location; +#pragma warning restore IL3000 + if (string.IsNullOrWhiteSpace(location)) + { + location = AppContext.BaseDirectory; + } + + return location; } ///