自动加载dll,加载dll中程序集的信息。

自动加载程序集,解析程序集中的方法。

  private static object Invoke(string lpFileName, string Namespace, string ClassName, string lpProcName, object[] ObjArray_Parameter)

         {

             try
{ // 载入程序集 Assembly MyAssembly = Assembly.LoadFrom(lpFileName); Type[] type = MyAssembly.GetTypes(); foreach (Type t in type) {// 查找要调用的命名空间及类 if (t.Namespace == Namespace && t.Name == ClassName) {// 查找要调用的方法并进行调用 MethodInfo m = t.GetMethod(lpProcName); if (m != null) {
object o = Activator.CreateInstance(t); return m.Invoke(o, ObjArray_Parameter); }
else Console.WriteLine(" 装载出错 !");
} } }//try catch (System.NullReferenceException e) { Console.WriteLine(e.Message); }//catch return (object); }// Invoke
上一篇:伟大的GCD和NSOperationQueue


下一篇:android 自定义 radiobutton 文字颜色随选中状态而改变