From 0184887cbf5b313e3a1498ea3a20cf417f0622be Mon Sep 17 00:00:00 2001 From: Fabian-Schmidt Date: Fri, 16 Aug 2024 12:46:30 -0700 Subject: [PATCH 1/2] `Assembly.Location` might return an empty string. `Path.GetDirectoryName` on Full Framework will then fail with `The path is not of a legal form.`. --- src/IKVM.Runtime/NativeLibrary.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/IKVM.Runtime/NativeLibrary.cs b/src/IKVM.Runtime/NativeLibrary.cs index 28f02a7bb1..a96054309e 100644 --- a/src/IKVM.Runtime/NativeLibrary.cs +++ b/src/IKVM.Runtime/NativeLibrary.cs @@ -73,7 +73,7 @@ public static NativeLibraryHandle Load(string nameOrPath) return h1; // start looking at assembly path, or path given by environmental variable - var asml = typeof(NativeLibrary).Assembly.Location is string s ? Path.GetDirectoryName(s) : null; + var asml = typeof(NativeLibrary).Assembly.Location is string s && !string.IsNullOrEmpty(s) ? Path.GetDirectoryName(s) : null; var root = Environment.GetEnvironmentVariable("IKVM_LIBRARY_PATH") ?? asml; // assembly possible loaded in memory: we have no available search path From b8b0c1ecade40e356f72156a0980cdc1ba132e85 Mon Sep 17 00:00:00 2001 From: Fabian Date: Thu, 15 Aug 2024 22:14:01 +0200 Subject: [PATCH 2/2] Update LibIkvm.cs Signed-off-by: Fabian --- src/IKVM.Runtime/LibIkvm.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/IKVM.Runtime/LibIkvm.cs b/src/IKVM.Runtime/LibIkvm.cs index 5ceb9cabba..4235c8b545 100644 --- a/src/IKVM.Runtime/LibIkvm.cs +++ b/src/IKVM.Runtime/LibIkvm.cs @@ -218,7 +218,7 @@ static nint Load() return h1; // start looking at assembly path, or path given by environmental variable - var asml = typeof(NativeLibrary).Assembly.Location is string s ? Path.GetDirectoryName(s) : null; + var asml = typeof(NativeLibrary).Assembly.Location is string s && !string.IsNullOrEmpty(s) ? Path.GetDirectoryName(s) : null; var root = Environment.GetEnvironmentVariable("IKVM_LIBRARY_PATH") ?? asml ?? AppContext.BaseDirectory; // assembly possible loaded in memory: we have no available search path