Reflection, invoke

Posted by Alaa' on Stack Overflow See other posts from Stack Overflow or by Alaa'
Published on 2010-05-22T23:59:59Z Indexed on 2010/05/23 0:00 UTC
Read the original article Hit count: 377

Filed under:
|

Hi, I have a dll file, and i took an object from it and called the functions inside this dll by the object, like this way:

Command testClass = (Command)assembly.CreateInstance(creatObject);
testClass.Execute();

anyway, the i used reflection from some reason. so i need to use invoke function & set values for variables, then calling the basic function Execute. Before: i wrote the following:

object returnValue = objectType.GetMethod("setValues").Invoke(classObject, arguments); testClass.Execute();

but it wasnt useful for me.

i used the following:

object returnValue = objectType.GetMethod("setValues").Invoke(classObject, arguments); object returnValue1 = objectType.GetMethod("Execute").Invoke(classObject, null);

i just want to ask if this is right, to calling the execute in this way, and by the way it works!

Thank you.

© Stack Overflow or respective owner

Related posts about c#

Related posts about reflection