未验证 提交 3e985173 编写于 作者: A Aleksey Kliger (λgeek) 提交者: GitHub

[reflection] Initialize default ALC gchandle in GetLoadContext (#60350)

If we try to get the ALC of an assembly from the default context before the
managed default ALC object has been created, the native gchandle has a null
target.
Ensure it is not null by explicitly referencing the Default ALC.

Fixes https://github.com/dotnet/runtime/issues/60348
上级 92bfaead
......@@ -80,6 +80,7 @@ internal static Assembly[] GetLoadedAssemblies()
// We only support looking up load context for runtime assemblies.
if (rtAsm != null)
{
var _ = Default; // ensure the default ALC is initialized.
RuntimeAssembly runtimeAssembly = rtAsm;
IntPtr ptrAssemblyLoadContext = GetLoadContextForAssembly(runtimeAssembly);
loadContextForAssembly = GetAssemblyLoadContext(ptrAssemblyLoadContext);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册