[HELP] Reflection

G

Guest

code:

Assembly myAssembly = Assembly.LoadFrom("Cargo.dll");
object myObject = myAssembly.CreateInstance("Cargos.Cargo");
myObject.GetType().InvokeMember("Load", BindingFlags.InvokeMethod, null,
myObject, null); <- this line, generate a exception

The exception "NotSupportedException" is generated. What is wrong ?

Rogerio
 
A

Alex Feinman [MVP]

InvokeMember does not work on CF. Use:

MethodInfo mi = myObject.GetType().GetMethod("Load");
mi.Invoke( myObject, new object[] { } );
 
G

Guest

Thanks.

Rogerio

Alex Feinman said:
InvokeMember does not work on CF. Use:

MethodInfo mi = myObject.GetType().GetMethod("Load");
mi.Invoke( myObject, new object[] { } );

--
Alex Feinman
---
Visit http://www.opennetcf.org
Rogerio Jun said:
code:

Assembly myAssembly = Assembly.LoadFrom("Cargo.dll");
object myObject = myAssembly.CreateInstance("Cargos.Cargo");
myObject.GetType().InvokeMember("Load", BindingFlags.InvokeMethod, null,
myObject, null); <- this line, generate a exception

The exception "NotSupportedException" is generated. What is wrong ?

Rogerio
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top