Skip to content

Commit

Permalink
fix invalid Uri error when running in a Single file application (#201)
Browse files Browse the repository at this point in the history
fallback to AppContext.BaseDirectory if Assembly.Location is null or empty when attempting to determine the location of the icu.net assembly. Assembly.Location will be an empty string when publishing SingleFile.
  • Loading branch information
hahn-kev authored Jul 4, 2024
1 parent 9bce747 commit b7b0666
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions source/icu.net/NativeMethods/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b7b0666

Please sign in to comment.