From 28335478bd9275078fde606f742b1ed1a57403fc Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sun, 2 Jul 2023 21:55:58 +0300 Subject: [PATCH] Fix managed library location resolver --- Source/Engine/Engine/NativeInterop.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Source/Engine/Engine/NativeInterop.cs b/Source/Engine/Engine/NativeInterop.cs index 4aedbe171..a6eb5368c 100644 --- a/Source/Engine/Engine/NativeInterop.cs +++ b/Source/Engine/Engine/NativeInterop.cs @@ -99,11 +99,14 @@ namespace FlaxEngine.Interop private static Assembly OnScriptingAssemblyLoadContextResolving(AssemblyLoadContext assemblyLoadContext, AssemblyName assemblyName) { // FIXME: There should be a better way to resolve the path to EditorTargetPath where the dependencies are stored - string editorTargetPath = Path.GetDirectoryName(nativeLibraryPaths.Keys.First(x => x != "FlaxEngine")); + foreach (string nativeLibraryPath in nativeLibraryPaths.Values) + { + string editorTargetPath = Path.GetDirectoryName(nativeLibraryPath); - var assemblyPath = Path.Combine(editorTargetPath, assemblyName.Name + ".dll"); - if (File.Exists(assemblyPath)) - return assemblyLoadContext.LoadFromAssemblyPath(assemblyPath); + var assemblyPath = Path.Combine(editorTargetPath, assemblyName.Name + ".dll"); + if (File.Exists(assemblyPath)) + return assemblyLoadContext.LoadFromAssemblyPath(assemblyPath); + } return null; } #endif