Unlike the other resolvers, this one *can* exist on the default ALC, so we have to add the null check like in GetAssemblyLoadContext.
Move the now-unused ResolveUsingResolvingEvent method back to the CoreCLR-specific file.
return context.GetResolvedUnmanagedDll(assembly, unmanagedDllName);
}
+ // This method is invoked by the VM to resolve an assembly reference using the Resolving event
+ // after trying assembly resolution via Load override and TPA load context without success.
+ private static Assembly? ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
+ {
+ AssemblyLoadContext context = (AssemblyLoadContext)(GCHandle.FromIntPtr(gchManagedAssemblyLoadContext).Target)!;
+ // Invoke the AssemblyResolve event callbacks if wired up
+ return context.ResolveUsingEvent(assemblyName);
+ }
+
[DllImport(RuntimeHelpers.QCall, CharSet = CharSet.Unicode)]
private static extern void LoadTypeForWinRTTypeNameInContextInternal(IntPtr ptrNativeAssemblyLoadContext, string typeName, ObjectHandleOnStack loadedType);
return context.ResolveUsingLoad(assemblyName);
}
- // This method is invoked by the VM to resolve an assembly reference using the Resolving event
- // after trying assembly resolution via Load override and TPA load context without success.
- private static Assembly? ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
- {
- AssemblyLoadContext context = (AssemblyLoadContext)(GCHandle.FromIntPtr(gchManagedAssemblyLoadContext).Target)!;
-
- // Invoke the AssemblyResolve event callbacks if wired up
- return context.ResolveUsingEvent(assemblyName);
- }
-
// This method is invoked by the VM to resolve a satellite assembly reference
// after trying assembly resolution via Load override without success.
private static Assembly? ResolveSatelliteAssembly(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
// success.
private static Assembly? MonoResolveUsingResolvingEvent(IntPtr gchALC, string assemblyName)
{
- return ResolveUsingResolvingEvent(gchALC, new AssemblyName(assemblyName));
+ AssemblyLoadContext context;
+ // This check exists because the function can be called early in startup, before the default ALC is initialized
+ if (gchALC == IntPtr.Zero)
+ context = Default;
+ else
+ context = (AssemblyLoadContext)(GCHandle.FromIntPtr(gchALC).Target)!;
+ return context.ResolveUsingEvent(new AssemblyName(assemblyName));
}
// Invoked by Mono to resolve requests to load satellite assemblies.