public static TRet InvokeMethod <TRet>(this IInvocation invocation, string methodName, params object[] args) { if (invocation.IsNull()) { throw new ArgumentNullException("invocation"); } if (methodName.IsNullOrEmpty()) { throw new ArgumentNullException("methodName"); } if (invocation.InvocationTarget.GetType().GetMethod(methodName).ReturnType == typeof(void)) { throw new ArgumentException("The method dose not have a return value, so please use \"InvokeMethod\" instead."); } var targetParams = invocation.MethodInvocationTarget.GetParameters(); var methodInfo = invocation.InvocationTarget.GetType().GetMethod(methodName); var parameters = methodInfo.GetParameters(); var arguments = GetArguments(args, targetParams, parameters); return(Invoke <TRet>(methodInfo, invocation.InvocationTarget, arguments)); }