Skip to content

Commit

Permalink
[Reflection] Loads mixed-mode assemblies containing fixups from file …
Browse files Browse the repository at this point in the history
…instead of from byte array (fixes issue stride3d#1066)
  • Loading branch information
azeno authored and xen2 committed Jun 24, 2021
1 parent fe6a604 commit 68ecc62
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion sources/core/Stride.Core.Design/Reflection/AssemblyContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,17 @@ private Assembly LoadAssemblyFromPathInternal([NotNull] string assemblyFullPath)
}

// TODO: Is using AppDomain would provide more opportunities for unloading?
assembly = pdbBytes != null ? Assembly.Load(assemblyBytes, pdbBytes) : Assembly.Load(assemblyBytes);
const uint unverifiableExecutableWithFixups = 0x80131019;
try
{
assembly = pdbBytes != null ? Assembly.Load(assemblyBytes, pdbBytes) : Assembly.Load(assemblyBytes);
}
catch (FileLoadException fileLoadException)
when ((uint)fileLoadException.HResult == unverifiableExecutableWithFixups)
{
// No way to load from byte array (see https://stackoverflow.com/questions/5005409/exception-with-resolving-assemblies-attempt-to-load-an-unverifiable-executable)
assembly = Assembly.LoadFrom(assemblyFullPath);
}
loadedAssembly = new LoadedAssembly(this, assemblyFullPath, assembly, dependenciesMapping);
loadedAssemblies.Add(loadedAssembly);
loadedAssembliesByName.Add(assemblyFullPath, loadedAssembly);
Expand Down

0 comments on commit 68ecc62

Please sign in to comment.