private void SwitchServiceAndDomain() { _currentDomain = _nextDomain; _currentService = _nextService; _nextDomain = null; _nextService = null; }
private void Load(string librariesDirectory, string targetDirectory, State state = null) { if (librariesDirectory != targetDirectory) { DirectoryCopyAndOverwrite(librariesDirectory, targetDirectory); } EmptyStagingFolder(); ConfigurationManager.RefreshSection("appSettings"); RefreshAdditionalConfigurationSections(); _nextDomain = AppDomain.CreateDomain("Ad2", null, _info); RemoteFactory factory = _nextDomain.CreateInstanceAndUnwrap("Connector", "Connector.RemoteFactory") as RemoteFactory; _nextService = factory.Create(targetDirectory, _dllName, _className); _folders.Swap(); _nextService.SetState(state); _nextService.Start(); }
private void Unload() { _currentService.Stop(); _currentService = null; AppDomain.Unload(_currentDomain); }