Fix native library lookup after hot reload
This commit is contained in:
@@ -58,19 +58,8 @@ namespace FlaxEngine.Interop
|
|||||||
if (!loadedNativeLibraries.TryGetValue(libraryName, out IntPtr nativeLibrary))
|
if (!loadedNativeLibraries.TryGetValue(libraryName, out IntPtr nativeLibrary))
|
||||||
{
|
{
|
||||||
if (!nativeLibraryPaths.TryGetValue(libraryName, out var nativeLibraryPath))
|
if (!nativeLibraryPaths.TryGetValue(libraryName, out var nativeLibraryPath))
|
||||||
{
|
|
||||||
nativeLibraryPath = libraryName;
|
nativeLibraryPath = libraryName;
|
||||||
|
|
||||||
// Check if any of the loaded assemblies has matching native module filename
|
|
||||||
foreach (var e in nativeLibraryPaths)
|
|
||||||
{
|
|
||||||
if (string.Equals(Path.GetFileNameWithoutExtension(e.Value), libraryName, StringComparison.Ordinal))
|
|
||||||
{
|
|
||||||
nativeLibraryPath = e.Value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nativeLibrary = NativeLibrary.Load(nativeLibraryPath, assembly, dllImportSearchPath);
|
nativeLibrary = NativeLibrary.Load(nativeLibraryPath, assembly, dllImportSearchPath);
|
||||||
loadedNativeLibraries.Add(libraryName, nativeLibrary);
|
loadedNativeLibraries.Add(libraryName, nativeLibrary);
|
||||||
assemblyOwnedNativeLibraries.Add(assembly, libraryName);
|
assemblyOwnedNativeLibraries.Add(assembly, libraryName);
|
||||||
|
|||||||
@@ -712,7 +712,8 @@ bool MAssembly::LoadImage(const String& assemblyPath, const StringView& nativePa
|
|||||||
// Provide new path of hot-reloaded native library path for managed DllImport
|
// Provide new path of hot-reloaded native library path for managed DllImport
|
||||||
if (nativePath.HasChars())
|
if (nativePath.HasChars())
|
||||||
{
|
{
|
||||||
RegisterNativeLibrary(assemblyPathAnsi.Get(), StringAnsi(nativePath).Get());
|
StringAnsi nativeName = _name.EndsWith(".CSharp") ? StringAnsi(_name.Get(), _name.Length() - 7) : StringAnsi(_name);
|
||||||
|
RegisterNativeLibrary(nativeName.Get(), StringAnsi(nativePath).Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
_hasCachedClasses = false;
|
_hasCachedClasses = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user