基本的に、私がインターネット上で検索した小さなことについて理解したことから、スレッドは AppDomain 間を通過できます。今、私は次のコードを書きました:
const string ChildAppDomain = "BlahBlah";
static void Main()
{
if (AppDomain.CurrentDomain.FriendlyName != ChildAppDomain)
{
bool done = false;
while (!done)
{
AppDomain mainApp = AppDomain.CreateDomain(ChildAppDomain, null, AppDomain.CurrentDomain.SetupInformation);
try
{
mainApp.ExecuteAssembly(Path.GetFileName(Application.ExecutablePath));
}
catch (Exception ex)
{
// [snip]
}
AppDomain.Unload(mainApp);
}
}
else
{
// [snip] Rest of the program goes here
}
}
これは正常に動作し、すべてが所定の位置に配置されています... メイン スレッドがプログラムの新しいバージョンに渡され、メイン アプリケーション本体の実行が開始されます。私の質問は、それを親に戻すにはどうすればよいAppDomain
ですか? これは可能ですか?私が達成しようとしているのは、2 つのドメイン間でクラスのインスタンスを共有することです。