即使我卸载 appdomain,我的 dll 也不会卸载
My dll won't unload even when i unload appdomain
我不明白为什么我的DLL在我做了AppDomain.Unload之后仍然在程序的内存中。我能做错什么吗?
AppDomain appDomain = AppDomain.CreateDomain("MyAuthDomain");
appDomain.DoCallBack(load_Auth);
var isLogin = (bool)appDomain.GetData("IsLogin");
AppDomain.Unload(appDomain);
private static void load_Auth()
{
var form = new Compiler(File.ReadAllBytes(Environment.CurrentDirectory + @"\form.dll"), "form");
form.InvokeMember("ShowDialog");
AppDomain.CurrentDomain.SetData("IsLogin", (bool)form.GetField("IsLogin"));
form.Unload();
}
P.S.
我如何理解 DLL 保留在内存中? NETUnpack 告诉我。
这对我有帮助
AppDomain.Unload(appDomain);
//GC
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
我不明白为什么我的DLL在我做了AppDomain.Unload之后仍然在程序的内存中。我能做错什么吗?
AppDomain appDomain = AppDomain.CreateDomain("MyAuthDomain");
appDomain.DoCallBack(load_Auth);
var isLogin = (bool)appDomain.GetData("IsLogin");
AppDomain.Unload(appDomain);
private static void load_Auth()
{
var form = new Compiler(File.ReadAllBytes(Environment.CurrentDirectory + @"\form.dll"), "form");
form.InvokeMember("ShowDialog");
AppDomain.CurrentDomain.SetData("IsLogin", (bool)form.GetField("IsLogin"));
form.Unload();
}
P.S. 我如何理解 DLL 保留在内存中? NETUnpack 告诉我。
这对我有帮助
AppDomain.Unload(appDomain);
//GC
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();