diff --git a/source/icu.net/NativeMethods/NativeMethods.cs b/source/icu.net/NativeMethods/NativeMethods.cs index 3d091fb5..cc6ab483 100644 --- a/source/icu.net/NativeMethods/NativeMethods.cs +++ b/source/icu.net/NativeMethods/NativeMethods.cs @@ -176,6 +176,12 @@ internal static string DirectoryOfThisAssembly #endif #if NET var managedPath = currentAssembly.Location; + // If the application is published as a single file, Assembly.Location will be an empty string. + // Per the warning https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/warnings/il3000 we should use AppContext.BaseDirectory instead. + if (string.IsNullOrEmpty(managedPath)) + { + managedPath = AppContext.BaseDirectory; + } #else var managedPath = currentAssembly.CodeBase ?? currentAssembly.Location; #endif