diff --git a/src/coreclr/vm/appdomain.cpp b/src/coreclr/vm/appdomain.cpp index c0741f5c50ee69..1ed177fdb6c7bc 100644 --- a/src/coreclr/vm/appdomain.cpp +++ b/src/coreclr/vm/appdomain.cpp @@ -1521,9 +1521,15 @@ bool SystemDomain::IsReflectionInvocationMethod(MethodDesc* pMeth) } CONTRACTL_END; - MethodTable* pCaller = pMeth->GetMethodTable(); + // Check for dynamically generated Invoke methods. + if (pMeth->IsDynamicMethod()) + { + if (strncmp(pMeth->GetName(), "InvokeStub_", ARRAY_SIZE("InvokeStub_") - 1) == 0) + return true; + } - // All Reflection Invocation methods are defined in CoreLib + // All other reflection invocation methods are defined in CoreLib. + MethodTable* pCaller = pMeth->GetMethodTable(); if (!pCaller->GetModule()->IsSystem()) return false; @@ -1579,13 +1585,6 @@ bool SystemDomain::IsReflectionInvocationMethod(MethodDesc* pMeth) if (CoreLibBinder::GetExistingClass(reflectionInvocationTypes[i]) == pCaller) return true; } - - // Check for dynamically generated Invoke methods. - if (pMeth->IsDynamicMethod()) - { - if (strncmp(pMeth->GetName(), "InvokeStub_", ARRAY_SIZE("InvokeStub_") - 1) == 0) - return true; - } } return false;