Finally, I have been able to get through reflection, a member of type Func<T, TResult>, now, how do I invoke it?
When I retrieve it, I do it through the Type.GetMembers method, and that returns a MemberInfo type that does not have a Invoke method; how can I invoke it?
Again people, thanks in advance! =)
In order to get a delegate to the method you need to call
MakeGenericMethodpassing in the generic type arguments – this returns an invokable delegate:If you are curious, the reason you need to do this is because the
MethodInfoinstance you currently hold is open, meaning that no generic type arguments have been bound to it (and naturally this method cannot be invoked which is why there is noInvokemethod available). By callingMakeGenericMethodyou are explicitly constructing the method with generic type arguments.For reference –
MakeGenericMethod: