Almost there,
try;
System.Object pObj = System.Activator.CreateInstance(oType);
System.Reflection.MethodInfo[] vMethods =
oType.GetMethods(BindingFlags.Public | BindingFlags.Instance);
for(int vIdx=0; vIdx< vMethods.Length; vIdx++)
{
string vName = vMethods[vIdx].Name;
System.Console.WriteLine("Invoke method " + vName + " with 2 string
arguements");
object[] vArgs = new object[2];
vArgs[0] = "My string arguement #1";
vArgs[1] = "My string arguement #2";
oType.InvokeMember(vName, BindingFlags.InvokeMethod, 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.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
how do i access methods when the .net assembly was loaded with late
biding?
class Class1
{
public static void Main()
{
System.Reflection.Assembly SampleAssembly;
SampleAssembly =
System.Reflection.Assembly.LoadFrom("C:\\SimpleSol utions\\asmload\\asmtoload \\bin\\Debug\\asmtoload.dll");
System.Type[] Types = SampleAssembly.GetTypes();
foreach (System.Type oType in Types)
{
System.Console.WriteLine(oType.Name.ToString());
string strName = oType.Name.ToString();
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.Threading.Thread.Sleep(5000);
}
}
}