From 0b6ff007c708c7ae3fda3c6d6fc76f48e7bd4484 Mon Sep 17 00:00:00 2001 From: Chris Dill Date: Fri, 28 Aug 2026 07:45:14 +0100 Subject: [PATCH 1/5] Make the custom dll import resolver optional --- Raylib-cs/interop/Raylib.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Raylib-cs/interop/Raylib.cs b/Raylib-cs/interop/Raylib.cs index c7ca8f9..78d492f 100644 --- a/Raylib-cs/interop/Raylib.cs +++ b/Raylib-cs/interop/Raylib.cs @@ -24,18 +24,6 @@ public static unsafe partial class Raylib public const float DEG2RAD = MathF.PI / 180.0f; public const float RAD2DEG = 180.0f / MathF.PI; - static Raylib() - { - // On WebAssembly (browser) the native library is statically linked into the main - // module, and P/Invokes are resolved by the runtime's built-in static-linking table. - // A custom resolver would override that and fail (there is no library to load), so we - // only install it on platforms where raylib is a separate dynamic library. - if (!OperatingSystem.IsBrowser()) - { - NativeLibrary.SetDllImportResolver(Assembly.GetExecutingAssembly(), ResolveDllImport); - } - } - public static IntPtr ResolveDllImport(string libraryName, Assembly assembly, DllImportSearchPath? searchPath) { IntPtr handle = IntPtr.Zero; From d32feb765a319e0ef1f172a9f8c078442d33080c Mon Sep 17 00:00:00 2001 From: Chris Dill Date: Thu, 3 Sep 2026 19:01:21 +0100 Subject: [PATCH 2/5] Improve custom dll import error handling * Use NativeLibrary.Load instead of NativeLibrary.TryLoad * Add error details to the DllNotFoundException --- Raylib-cs/interop/Raylib.cs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Raylib-cs/interop/Raylib.cs b/Raylib-cs/interop/Raylib.cs index 78d492f..4b81f35 100644 --- a/Raylib-cs/interop/Raylib.cs +++ b/Raylib-cs/interop/Raylib.cs @@ -26,21 +26,31 @@ public static unsafe partial class Raylib public static IntPtr ResolveDllImport(string libraryName, Assembly assembly, DllImportSearchPath? searchPath) { - IntPtr handle = IntPtr.Zero; - string libraryPath = GetLibraryPath(libraryName); - - if (NativeLibrary.TryLoad(libraryName, assembly, searchPath, out handle)) + string resolveNameError; + try { + IntPtr handle = NativeLibrary.Load(libraryName, assembly, searchPath); return handle; } - - if (NativeLibrary.TryLoad(libraryPath, out handle)) + catch (Exception ex) { + resolveNameError = ex.Message; + } + + string resolvePathError; + string libraryPath = GetLibraryPath(libraryName); + try + { + IntPtr handle = NativeLibrary.Load(libraryPath); return handle; } + catch (Exception ex) + { + resolvePathError = ex.Message; + } throw new DllNotFoundException( - $"Failed to load {libraryName}." + string.Join("\n", string.Empty, resolveNameError, resolvePathError) ); } From d7b4d3c18f95f1eff9d19a91b1f428ef7d917780 Mon Sep 17 00:00:00 2001 From: Chris Dill Date: Fri, 4 Sep 2026 20:01:49 +0100 Subject: [PATCH 3/5] Update release version to 8.1.0 --- Directory.Build.props | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index bbab19a..92fc659 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - 8.1.0-rc.1 + 8.1.0