if you are not using interface approach, then you have to use Reflection, see
Invoking Assembly Dynamically using Reflection]
http://www.c-sharpcenter.com/CSNET/dynamicinvoke.asp

解决方案 »

  1.   

    http://www.c-sharpcenter.com/CSNET/dynamicinvoke.asp
    我怎么访问不了
      

  2.   

    seehttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemReflectionAssemblyClassTopic.asp
    using System;
    using System.Reflection;
    public class LoadInvoke
    {
        public static void Main(string[] args)
        {
            Assembly a = Assembly.LoadFrom(args[0]);
            Type[] mytypes = a.GetTypes();
            BindingFlags flags = (BindingFlags.NonPublic | BindingFlags.Public | 
                BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly);        foreach(Type t in mytypes)
            {
                MethodInfo[] mi = t.GetMethods(flags);
                Object obj = Activator.CreateInstance(t);            foreach(MethodInfo m in mi)
                {
                    m.Invoke(obj, null);
                }
            }
        }
    }
      

  3.   


    如下:Type type = Type.GetType( "SystemManage.Portal,SystemManage");
    MethodInfo info = type.GetMethod( "GetPortal" );
    object Portal = Activator.CreateInstance( type );//动态创建一个实例 object[] args = new object[1];(构造参数)
    args[0] = action;
    Form ShowForm = (Form)info.Invoke( Portal,args );//运行方法
        
     
      
    SystemManage.Portal里面有一个方法是GetMethod(string path),返回一个form这里有几个关于反射的帖子
    http://www.csdn.net/Develop/Read_Article.asp?Id=15284
    http://www.csdn.net/Develop/Read_Article.asp?Id=15285
    http://www.csdn.net/Develop/Read_Article.asp?Id=15286