You are not logged in.
Hi.
I want to call a method indirectly by using MethodInfo.Invoke. For methods without a parameter it works allready, but when trying to pass parameters it throws an exception.
This is my test object:
public class Test{
public void method(int a, float b){
Console.WriteLine("{0} {1}", a, b);
}
}
And this way I try to call them
Test my_test = new Test();
object[] par = new object[2] {2, 2.0};
MethodInfo meth = my_test.GetType().GetMethod("method");
meth.Invoke(my_test, BindingFlags.Default, null, par, null);
Mono says that I have to pass an object[] array with all paremters inside in the exact same order and the same type as the method expect me to. But I guess that I do, at least 2 and 2.0 should be int and float.
I hope that someone of you got an idea how to deal with this.
Offline
object[] par = new object[2] {2, 2.0f};
you also don't need the full method.
meth.Invoke(my_test, par);
will work just fine.
Offline
thanks. work's like a charm.
Offline