Use manual pdb file loading for debug symbols in C#

This commit is contained in:
Wojciech Figat
2023-01-04 09:56:58 +01:00
parent 26f8e5aa9e
commit 0b8d4850f0
3 changed files with 15 additions and 7 deletions

View File

@@ -2463,7 +2463,19 @@ namespace FlaxEngine
Marshal.Copy(data, raw, 0, len);
using MemoryStream stream = new MemoryStream(raw);
Assembly assembly = scriptingAssemblyLoadContext.LoadFromStream(stream);
#if !BUILD_RELEASE
var pdbPath = Path.ChangeExtension(assemblyPath, "pdb");
Assembly assembly;
if (File.Exists(pdbPath))
{
using FileStream pdbStream = new FileStream(Path.ChangeExtension(assemblyPath, "pdb"), FileMode.Open);
assembly = scriptingAssemblyLoadContext.LoadFromStream(stream, pdbStream);
}
else
#endif
{
assembly = scriptingAssemblyLoadContext.LoadFromStream(stream);
}
NativeLibrary.SetDllImportResolver(assembly, NativeLibraryImportResolver);
// Assemblies loaded via streams have no Location: https://github.com/dotnet/runtime/issues/12822