Almost there,
try;
System.Object pObj = System.Activato r.CreateInstanc e(oType);
System.Reflecti on.MethodInfo[] vMethods =
oType.GetMethod s(BindingFlags. Public | BindingFlags.In stance);
for(int vIdx=0; vIdx< vMethods.Length ; vIdx++)
{
string vName = vMethods[vIdx].Name;
System.Console. WriteLine("Invo ke method " + vName + " with 2 string
arguements");
object[] vArgs = new object[2];
vArgs[0] = "My string arguement #1";
vArgs[1] = "My string arguement #2";
oType.InvokeMem ber(vName, BindingFlags.In vokeMethod, null, pObj, vArgs);
}
You will get some errors if you run this "as is", due to the fact that all
the methods will not take 2 string arguements - but this should get you
heading in the right direction (for all you cross posts!)
- Colin
"Daniel" <so************ *******@yahoo.c om> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
how do i access methods when the .net assembly was loaded with late
biding?
class Class1
{
public static void Main()
{
System.Reflecti on.Assembly SampleAssembly;
SampleAssembly =
System.Reflecti on.Assembly.Loa dFrom("C:\\Simp leSolutions\\as mload\\asmtoloa d \\bin\\Debug\\a smtoload.dll");
System.Type[] Types = SampleAssembly. GetTypes();
foreach (System.Type oType in Types)
{
System.Console. WriteLine(oType .Name.ToString( ));
string strName = oType.Name.ToSt ring();
System.Object pObj = SampleAssembly. CreateInstance( "asmtoload" + "." +
strName);
//System.Console. WriteLine(pObj. IOCTL("foo")); THIS IS A BUILD ERROR
BECAUSE IOCTL method is not accessible, how to access method if type info
of dynamicaly loaded dll?
System.Threadin g.Thread.Sleep( 5000);
}
}
}