Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,33 @@ private Assembly ResolveAssembly(BamlAssembly bamlAssembly)
}

AssemblyName assemblyName = new AssemblyName(bamlAssembly.Name);

#if NETCOREAPP
// Try to resolve the requested assembly in the same AssemblyLoadContext as the local assembly which requests it.
if (_localAssembly != null)
{
System.Runtime.Loader.AssemblyLoadContext alc = System.Runtime.Loader.AssemblyLoadContext.GetLoadContext(_localAssembly);

if (alc != null)
{
try
{
bamlAssembly.Assembly = alc.LoadFromAssemblyName(assemblyName);
if (bamlAssembly.Assembly != null)
{
return bamlAssembly.Assembly;
}
}
catch (System.Exception ex) when (ex is System.IO.FileNotFoundException ||
ex is System.IO.FileLoadException ||
ex is System.BadImageFormatException)
{
// Fallback to legacy resolution logic.
}
}
}
#endif

bamlAssembly.Assembly = MS.Internal.WindowsBase.SafeSecurityHelper.GetLoadedAssembly(assemblyName);
Comment thread
cunhamauro marked this conversation as resolved.
if (bamlAssembly.Assembly == null)
{
Expand Down