/// <summary> /// Shutdown the application host's domain. The AppHost cannot be used after this. /// </summary> public void Dispose() { var childDomain = _appDomainProxy.CurrentDomain(); var maxGen = GC.MaxGeneration; try { GC.Collect(maxGen, GCCollectionMode.Forced, blocking: true); AppDomain.Unload(childDomain); } catch (CannotUnloadAppDomainException) { GC.Collect(maxGen, GCCollectionMode.Forced, blocking: true); AppDomain.Unload(childDomain); } }