N
nfedin
I am writing a testing application that uses reflection to open
assemblies and call methods.
I have a function that looks like this...
public void Method1 (int[] IDArray, bool SomethingElse){
....
}
When I prepare the parameters for the above function, I create and
integer array and give it some values
i.e.
int[] IDArray = new int[3]{1,2,3};
Everything works fine up to this point.
I now need to create the object array that Method.Invoke requires.
object[] Parameters = new object[2];
Parameters[0] = IDArray;
Parameters[1] = true;
Now I want to invoke the method.
MethodInfo mInfo = ......
object instance = Activator.CreateInstance(...);
mInfo.Invoke(instance,Parameters);
At this point I get an error...it tells me that Object cannot
implicitly convert to the parameter type(int[]).
All other data types and objects work fine. How can I implement
Method.Invoke to pass an array of values(not just int, it could be any
type)?
Thanks,
Neil
assemblies and call methods.
I have a function that looks like this...
public void Method1 (int[] IDArray, bool SomethingElse){
....
}
When I prepare the parameters for the above function, I create and
integer array and give it some values
i.e.
int[] IDArray = new int[3]{1,2,3};
Everything works fine up to this point.
I now need to create the object array that Method.Invoke requires.
object[] Parameters = new object[2];
Parameters[0] = IDArray;
Parameters[1] = true;
Now I want to invoke the method.
MethodInfo mInfo = ......
object instance = Activator.CreateInstance(...);
mInfo.Invoke(instance,Parameters);
At this point I get an error...it tells me that Object cannot
implicitly convert to the parameter type(int[]).
All other data types and objects work fine. How can I implement
Method.Invoke to pass an array of values(not just int, it could be any
type)?
Thanks,
Neil