assembly method invoke

Mar 18, 2010 at 9:54 AM
Edited Mar 18, 2010 at 10:31 AM

Assembly assembly = Assembly.LoadFrom(@"D:\Work\ex\project5stepwrapper.dll");

foreach (Type Cls in assembly.GetTypes())

{

if (Cls.IsInterface)

continue;

object instance = Activator.CreateInstance(Cls);

foreach (MethodInfo Method in Cls.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))

foreach (ParameterInfo pi1 in ((MethodInfo)Method).GetParameters())

Method.Invoke(instance, new object[] { pi1 });

}

error messege is coming : Object of type 'System.Reflection.RuntimeParameterInfo' cannot be converted to type 'System.String&'.

------------------------------------------------------------------------------------------------

Then i try with FastInvoker.dll

class

X

{

public

string o;

public

string oo { get; set; }

public

void Method()

}

------------------------------------------------------------------------------------------------

X

ss = new X();

Assembly

assembly = Assembly.LoadFrom(@"D:\Work\ex\project5stepwrapper.dll");

foreach

{

(Type Cls in assembly.GetTypes())

if

(Cls.IsInterface)

continue

;

object

instance = Activator.CreateInstance(Cls);

foreach

{

FastInvoker.

(MethodInfo Method in Cls.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) MethodInvoker<X> method = new FastInvoker.MethodInvoker<X>(Method);

foreach

{

(ParameterInfo pi1 in ((MethodInfo)Method).GetParameters())

//string returnValue = (string)Method.Invoke(instance, new object[] { pi1 });

method.Invoke(ss,

new object[] { pi1 });

}

}

}

then error was : Unable to cast object of type 'System.Reflection.RuntimeParameterInfo' to type 'System.String'.

------------------------------------------------------------------------------------------------

any solution to be appreciated and i shall be greateful...

Thanks a lot