Reputation: 875
I have pretty simple code like:
var childDomain = AppDomain.CreateDomain("child");
childDomain.ExecuteAssembly("WpfApplication1.exe");
AppDomain.Unload(childDomain);
But it closes app at all. I don't have any references to WpfApplication1.exe in parent app. I read this - AppDomain Unload killing Parent AppDomain but it hadn't helped.
So what I'm doing wrong?
Upvotes: 1
Views: 471
Reputation: 875
The problem was in this line: childDomain.ExecuteAssembly("WpfApplication1.exe");
ExecuteAssembly method runs application on the same thread as caller. So unloading is killing the main thread. The solution is run child app in new STA thread.
Upvotes: 2