I've looked at other questions like this but am having no luck. I feel like I'm dancing around the answer.
After using reflection to call MethodInfo myMethod = MakeGenericMethod(Type.GetType(MyClass))
I have a MethodInfo
object that looks like this in the debugger:
myMethod --> Int32 Count[MyClass](System.Data.IDbConnection, ICriteria)
...and I try to call it like so using Invoke:
ICriteria myCriteria = new Criteria("some info here");
//'connection' is an object of type System.Data.IDBConnection
int count = (int)myMethod.Invoke(connection, new object [] {myCriteria});
...but when I do this I get a parameter count mismatch, and I'm scratching my head as to why.
Is it because it's a generic method, possibly? Or perhaps the fact that Count
is an extension method on connection
?
For reference, a non-reflective, straighforward way of calling my method would be something like int count = connection.Count<MyRow>(new Criteria("some info here"));