一个.exe文件能不能动态调用一个.dll文件?就是说exe文件是一个父窗体,dll文件是一个个子窗体,但是两个文件是完成独立的,没有添加引用这样的话能不能用程序实现exe调用dll文件?

解决方案 »

  1.   

    of koz it could~~用反射!!!!!
      

  2.   

    Assembly a = Assembly.LoadFrom(Application.StartupPath + "\\" + dllname + ".dll");

    //Get the type to use.
    Type myType = a.GetType(formclassname);

    //Create an instance.
    Object obj = Activator.CreateInstance(myType);

    //类型转换
    System.Windows.Forms.Form f = (System.Windows.Forms.Form)obj; f.MdiParent = this;

    pnlRight.Controls.Clear();

    f.Dock = System.Windows.Forms.DockStyle.Fill;

    pnlRight.Controls.Add(f); f.Show();