200分求:如何在MDI窗休加载DLL窗体? ?应该是个很简单的问题吧。在类库项目里面添加一个窗体不就行了吗?在你所说的IDE的窗体里面引用这个类库,调用这个类库中的方法,或者是使用反射调用这个dll中的方法。exe和dll差不多,都叫程序集。不知道是不是你想要的效果。还是我理解错了呢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 谢谢!我要的是在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(); }//classusing 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#能否做到! 这篇文章和代码看过吗从 dll 程序集中动态加载窗体 [原创] 用dll方式封装mdi子窗体 [难度][高分] 请教如何获取拉姆达表达式的值 Marshal.SizeOf返回值不正确? c# Image Fromfile 资源释放 如何受一个事件触发时,自动将自己变为当前的活动窗口? 双显卡,用WinForm怎样可以前后台切换呢? DropDownList C# 的对象如何通过循环得到对象的属性名和值? 用session能否传递DataGrid中的模板列(TemplateColumn) 中英文两种语言的resx,为什么中文出现在默认的resx里面,而英文的没有? 那本书比《C#高级编程》更好?有详细理由者200分(分两次给您) 请教几个关于日志存储的问题 数据库问题
我要的是在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#能否做到!
从 dll 程序集中动态加载窗体 [原创]