internal static T GetDelegateForInvokeExact <T>(MethodHandle mh) where T : class { MethodType type = mh.type(); if (mh._invokeExactDelegate == null) { if (type._invokeExactDynamicMethod == null) { type._invokeExactDynamicMethod = DynamicMethodBuilder.CreateInvokeExact(type); } mh._invokeExactDelegate = type._invokeExactDynamicMethod.CreateDelegate(GetDelegateTypeForInvokeExact(type), mh); T del = mh._invokeExactDelegate as T; if (del != null) { return(del); } } throw Invokers.newWrongMethodTypeException(GetDelegateMethodType(typeof(T)), type); }