I am trying to figure out AppDomains.
I use following code to run the current application once more in a new child AppDomain with an argument:
AppDomain domain = AppDomain.CreateDomain("NewAppDomain", null);
domain.ExecuteAssemblyByName(currentAssembly.FullName, "argument");
It works fine, however, when I try to unload it via AppDomain.Unload(domain);
, it also kills Parent it was called from.
In the debug output I can see following errors:
Exception thrown: 'System.Threading.ThreadAbortException' in mscorlib.dll
Exception thrown: 'System.Threading.ThreadAbortException' in mscorlib.dll
Exception thrown: 'System.Threading.ThreadAbortException' in TestAppDomain.exe
Exception thrown: 'System.Threading.ThreadAbortException' in System.Windows.Forms.dll
Exception thrown: 'System.AppDomainUnloadedException' in TestAppDomain.exe
I am not sure what is the issue here, how can I correctly unload such child AppDomain without killing Parent?
Main thread was not stopped completely before I tried to unload the AppDomain. Stopping it correctly fixed the error.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.