From f77b153512a28ef5bcf5ecdab18a82b0590c8248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20L=C3=BCbe=C3=9F?= Date: Thu, 17 Jul 2025 15:13:21 +0200 Subject: [PATCH] Fixed DLL-Import for ImGui.NET --- ScriptCore/ScriptGlue.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ScriptCore/ScriptGlue.cs b/ScriptCore/ScriptGlue.cs index bf64a5f..db031b6 100644 --- a/ScriptCore/ScriptGlue.cs +++ b/ScriptCore/ScriptGlue.cs @@ -40,14 +40,20 @@ internal static unsafe partial class ScriptGlue static ScriptGlue() { NativeLibrary.SetDllImportResolver(typeof(ScriptGlue).Assembly, ImportResolver); + // TODO: With this we can actually use the official ImGui.NET-Branch in the future! + NativeLibrary.SetDllImportResolver(typeof(ImGui).Assembly, ImportResolver); } private static IntPtr ImportResolver(string libraryName, Assembly assembly, DllImportSearchPath? searchPath) { if (libraryName == "__Internal") { - // Lade die aktuelle exe selbst - return NativeLibrary.Load(Process.GetCurrentProcess().MainModule.FileName); + string? mainModuleFileName = Process.GetCurrentProcess().MainModule?.FileName; + + if (mainModuleFileName != null) + return NativeLibrary.Load(mainModuleFileName); + + throw new DllNotFoundException("Failed to resolve import to current executable: Could not find file name of main module."); } return IntPtr.Zero;