?应该是个很简单的问题吧。在类库项目里面添加一个窗体不就行了吗?在你所说的IDE的窗体里面引用这个类库,调用这个类库中的方法,或者是使用反射调用这个dll中的方法。exe和dll差不多,都叫程序集。不知道是不是你想要的效果。还是我理解错了呢。

解决方案 »

  1.   

    谢谢!
    我要的是在MDI窗里动态加载和卸载DLL的,加载的窗体是是MDI里的子体
    http://www.kc268.com/tj-mj/image/2.png        private void button1_Click(object sender, EventArgs e)
            {
                string callingDomainName = AppDomain.CurrentDomain.FriendlyName;//Thread.GetDomain().FriendlyName;
                Console.WriteLine(callingDomainName);
                AppDomain ad = AppDomain.CreateDomain("DLL Unload test");
                ProxyObject obj = (ProxyObject)ad.CreateInstanceFromAndUnwrap(@"UnloadDll.exe", "ProxyObject");
                obj.LoadAssembly();
                obj.Invoke("TestDll.Class1", "Test","HI");
                AppDomain.Unload(ad);
                obj = null;
                Console.ReadLine();
            }//class
    using System;
    using System.Reflection;
    public class ProxyObject : MarshalByRefObject
    {
        Assembly assembly = null;
        public void LoadAssembly()
        {
            assembly = Assembly.LoadFile(@"TestDLL.dll");
        }
        public bool Invoke(string fullClassName, string methodName, params Object[] args)
        {
            if (assembly == null)
                return false;
            Type tp = assembly.GetType(fullClassName);
            if (tp == null)
                return false;
            MethodInfo method = tp.GetMethod(methodName);
            if (method == null)
                return false;
            Object obj = Activator.CreateInstance(tp);
            method.Invoke(obj, args);
            return true;
        }
    }不知道C#能否做到!
      

  2.   

    这篇文章和代码看过吗
    从 dll 程序集中动态加载窗体 [原创]
      

  3.   

    用dll方式封装mdi子窗体