M
Manfred Braun
Hi All,
I am able to invoke some methods from an instance of a loaded assembly, but
I am not able to invoke the loaded assemblie's "Main" method. I try it this
way:
Assembly assembly = Assembly.LoadFrom(config.exec.assemblyName);
tRunnable = assembly.GetType(config.exec.typeName);
object runner = assembly.CreateInstance("Demo");
Type type = runner.GetType();
//MethodInfo mi = type.GetMethod("Main", new Type[]{typeof(string[])});
MethodInfo mi = type.GetMethod("Main");
Console.WriteLine("Have method named:{0}", mi.Name);
string[] p = new string[]{"x"};
mi.Invoke(runner, p); //CRASH:
Unhandled Exception: System.ArgumentException: Object type cannot be
converted to target type.
the Main method of the loaded assembly is:
public static void Main(string[] args)
{
Demo d = new Demo();
d.Init("m1", args);
d.Run();
}
I am able to invoke other (instance!!!-)methods of the assembly!
Any thoughts, tips, hints or pointer to further information are really very
welcomed!!!!
Best regards,
Manfred Braun
(Private)
Mannheim
Germany
mailto:[email protected]
(Remove the anti-spam-underscore to mail me!)
I am able to invoke some methods from an instance of a loaded assembly, but
I am not able to invoke the loaded assemblie's "Main" method. I try it this
way:
Assembly assembly = Assembly.LoadFrom(config.exec.assemblyName);
tRunnable = assembly.GetType(config.exec.typeName);
object runner = assembly.CreateInstance("Demo");
Type type = runner.GetType();
//MethodInfo mi = type.GetMethod("Main", new Type[]{typeof(string[])});
MethodInfo mi = type.GetMethod("Main");
Console.WriteLine("Have method named:{0}", mi.Name);
string[] p = new string[]{"x"};
mi.Invoke(runner, p); //CRASH:
Unhandled Exception: System.ArgumentException: Object type cannot be
converted to target type.
the Main method of the loaded assembly is:
public static void Main(string[] args)
{
Demo d = new Demo();
d.Init("m1", args);
d.Run();
}
I am able to invoke other (instance!!!-)methods of the assembly!
Any thoughts, tips, hints or pointer to further information are really very
welcomed!!!!
Best regards,
Manfred Braun
(Private)
Mannheim
Germany
mailto:[email protected]
(Remove the anti-spam-underscore to mail me!)