From c374127de1d7979f218a49e0f29f5ba9cbed4886 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 25 Sep 2023 16:34:01 +0200 Subject: [PATCH] Fix error when loading project on non-ASCII path #1439 --- Source/Engine/Engine/NativeInterop.Unmanaged.cs | 2 +- Source/Engine/Scripting/Runtime/DotNet.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Source/Engine/Engine/NativeInterop.Unmanaged.cs b/Source/Engine/Engine/NativeInterop.Unmanaged.cs index 8198b0aed..cfa71f97f 100644 --- a/Source/Engine/Engine/NativeInterop.Unmanaged.cs +++ b/Source/Engine/Engine/NativeInterop.Unmanaged.cs @@ -853,7 +853,7 @@ namespace FlaxEngine.Interop } try { - string assemblyPath = Marshal.PtrToStringAnsi(assemblyPathPtr); + string assemblyPath = Marshal.PtrToStringUni(assemblyPathPtr); Assembly assembly; #if FLAX_EDITOR diff --git a/Source/Engine/Scripting/Runtime/DotNet.cpp b/Source/Engine/Scripting/Runtime/DotNet.cpp index eccd3cf71..4a84fca0a 100644 --- a/Source/Engine/Scripting/Runtime/DotNet.cpp +++ b/Source/Engine/Scripting/Runtime/DotNet.cpp @@ -703,11 +703,10 @@ bool MAssembly::LoadImage(const String& assemblyPath, const StringView& nativePa { // TODO: Use new hostfxr delegate load_assembly_bytes? (.NET 8+) // Open .Net assembly - const StringAnsi assemblyPathAnsi = assemblyPath.ToStringAnsi(); const char* name = nullptr; const char* fullname = nullptr; static void* LoadAssemblyImagePtr = GetStaticMethodPointer(TEXT("LoadAssemblyImage")); - _handle = CallStaticMethod(LoadAssemblyImagePtr, assemblyPathAnsi.Get(), &name, &fullname); + _handle = CallStaticMethod(LoadAssemblyImagePtr, assemblyPath.Get(), &name, &fullname); MCore::GC::FreeMemory((void*)name); MCore::GC::FreeMemory((void*)fullname); if (_handle == nullptr)