diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs index 8f5426b0c2804..bda68c3c44d14 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs @@ -143,6 +143,16 @@ public DependencyList Import() { _dependencies.Add(GetHelperEntrypoint(ReadyToRunHelper.MonitorEnterStatic), reason); _dependencies.Add(GetHelperEntrypoint(ReadyToRunHelper.MonitorExitStatic), reason); + + MethodDesc method = _methodIL.OwningMethod; + if (method.OwningType.IsRuntimeDeterminedSubtype) + { + _dependencies.Add(GetGenericLookupHelper(ReadyToRunHelperId.NecessaryTypeHandle, method.OwningType), reason); + } + else + { + _dependencies.Add(_factory.NecessaryTypeSymbol(method.OwningType), reason); + } } else {