In my code I very specifically ask for the method which has the right number of arguments:
var matchingMethods = pType.GetMethods()
.Where(m => m.Name.ToUpper() == method.ToUpper() && !m.IsGenericMethod
&& m.GetParameters().ToList().Count == args.Count())
.ToList();
And I get one and only one match. I invoke it like so:
var items = mi.Invoke(classInstance, args.ToArray<object>());
But then I get "Parameter count mismatch". Funny thing is that the debugger breaks on the method invoked and it looks fine. There is one argument sent in and only one, which is as it should be.
Aucun commentaire:
Enregistrer un commentaire