应用反射机制,具体的可以看SDK文档,很容易的

解决方案 »

  1.   

    扫描目录看这里
    http://chs.gotdotnet.com/QuickStart/howto/default.aspx?url=/quickstart/howto/doc/Directory.aspx创建实例看这里
    http://chs.gotdotnet.com/QuickStart/howto/default.aspx?url=/quickstart/howto/doc/GetTypes.aspx
      

  2.   

    //所有加载进来的程序集都存放在ArrayList中
    ArrayList dllList=new ArrayList();
    Foreach(string f in Directory.GetFiles("c:\", "*.dll")
    {
       dllList.Add( Assembly.LoadFrom(f) );
    }
    ---------------------------------------
    实际上这样的程序是没有意义的,因为你无法控制加载进来的程序集。
    因此,你应该在主程序声明一个接口,然后在dll中实现这个接口,这样主程序就可以通过调用接口来控制加载进来的程序集了。这其实也就是.net中插件的实现方法.
      

  3.   

    foreach(string f in Directory.GetFiles("c:\\","*.dll")
    {
       
       Assembly a=Assembly.Load(f);
       Type[] types=a.GetTypes();
       foreach(Type type in types)
       {
         if(type.BaseType==typeof(Control)
         {
           Control c=(Control)Activator.CreateInstance(type)
         }
       }
    }
      

  4.   

    接口的方法过于是一个好机制,但对于目前.net已经有了很好的自定义属性时,反射就更合适,当然可以将两者结合起来