Calling generic method using reflection in .NET [duplicate]

You’re not using the result of MakeGenericMethod – which doesn’t change the method you call it on; it returns another object representing the constructed method. You should have something like:

method = method.MakeGenericMethod(typeof(SomeClass));
var result = method.Invoke(service, null);

(or use a different variable, of course).

Leave a Comment