类似这个,把类换成Delegate试试
// cs_operator_typeof.cs
// Using typeof operator
using System;
using System.Reflection;public class MyClass 
{
   public int intI;
   public void MyMeth() 
   {
   }   public static void Main() 
   {
      Type t = typeof(MyClass);      // alternatively, you could use
      // MyClass t1 = new MyClass();
      // Type t = t1.GetType();      MethodInfo[] x = t.GetMethods();
      foreach (MethodInfo xtemp in x) 
      {
         Console.WriteLine(xtemp.ToString());
      }      Console.WriteLine();      MemberInfo[] x2 = t.GetMembers();
      foreach (MemberInfo xtemp2 in x2) 
      {
         Console.WriteLine(xtemp2.ToString());
      }
   }
}

解决方案 »

  1.   

    我是调用DGTripleMasterDetails中的Form1类的GetGrandChildTable方法.
    这里也可以是DLL.我不知道你是不是要实现这样.CreateInstance便可以实例化一个类了.
    实例好的类实例用GetType().GetMethod使用其中的一个方法.似乎不管这个方法是否是private.这个很流氓的.我觉得.HEHE.
    Assembly assm = Assembly.LoadFrom(@"C:\begcsharp\chapter2  \DGTripleMasterDetails\bin\Debug\DGTripleMasterDetails.exe");
    object objForm = assm.CreateInstance("DGTripleMasterDetails.Form1");
    MethodInfo mi = objForm.GetType().GetMethod("GetGrandChildTable",BindingFlags.FlattenHierarchy | BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | 
    BindingFlags.Static);
    object obj = mi.Invoke(objForm,null);
    DataTable dt = (DataTable)mi.Invoke(assm,null);
    我用DATATABLE,是因为GetGrandChildTable返回的是该类型的.
      

  2.   

    因为Delegate类隐藏了没有参数的构造函数,无法直接用用反射来创造,你必须要指定一个回调函数,而且在实例化的时候Delegate的构造函数要检查这个回调函数的原型是否和这个Delegate相同,所以无法蒙混过关。但若是通过实例化后获取Method参数来解析原型,那就无意义了,因为这样的话我在编译期就知道原型了,何必还要用反射呢?我用反射就是要得到某个Delegate的原型。
      

  3.   

    反编译软件 Reflector可以查看Delegate原型。我曾试图用它本身来反编译它本身,但没找到相关代码
      

  4.   

    所有Delegate类都会定义一个Invoke方法,它的函数原型和Delegate的C#声明完全一样:using System;
    using System.Reflection;namespace JoyCode.QQChen.CSharp {
    public delegate string Foo(int i, object obj); public class StrTest {
    public static void Main() {
    Type t = typeof(Foo);
    MethodInfo m = t.GetMethod("Invoke");

    Console.WriteLine("Delegate Return Type: " + m.ReturnType);
    ParameterInfo[] pinfos = m.GetParameters();
    Console.Write("Delegate Parameters: (");
    for(int i = 0; i < pinfos.Length; ++ i) {
    Console.Write(pinfos[i].ParameterType);
    if (i != pinfos.Length - 1) Console.Write(", ");
    }
    Console.WriteLine(")");
    }
    }
    }