public override void Install(IDictionary stateSaver) { if (_installers != null) { Installers.AddRange(_installers); } var serviceName = BuildServiceName(_settings); _logWriter.InfoFormat(Properties.Resources.InstallingServiceIsStarted, serviceName); try { base.Install(stateSaver); _installTransaction.Execute(_settings); _logWriter.InfoFormat(Properties.Resources.InstallingServiceIsSuccessfullyCompleted, serviceName); } catch (Exception error) { error = new InstallException(string.Format(Properties.Resources.InstallingServiceFailed, serviceName), error); _logWriter.ErrorFormat(Properties.Resources.InstallingServiceIsCompletedWithErrors, serviceName, error); throw error; } }
public override void Uninstall(IDictionary savedState) { if (_installers != null) { Installers.AddRange(_installers); } var serviceName = BuildServiceName(_settings); _logWriter.InfoFormat(Properties.Resources.UninstallingServiceIsStarted, serviceName); var errors = new List <Exception>(); try { _installTransaction.Rollback(_settings); } catch (Exception error) { errors.Add(error); } try { base.Uninstall(savedState); } catch (Exception error) { errors.Add(error); } if (errors.Count > 1) { Exception error = new AggregateException(string.Format(Properties.Resources.UninstallingServiceFailed, serviceName), errors); error = new InstallException(string.Format(Properties.Resources.UninstallingServiceFailed, serviceName), error); _logWriter.ErrorFormat(Properties.Resources.UninstallingServiceIsCompletedWithErrors, serviceName, error); throw error; } if (errors.Count == 1) { var error = new InstallException(string.Format(Properties.Resources.UninstallingServiceFailed, serviceName), errors[0]); _logWriter.ErrorFormat(Properties.Resources.UninstallingServiceIsCompletedWithErrors, serviceName, error); throw error; } _logWriter.InfoFormat(Properties.Resources.UninstallingServiceIsSuccessfullyCompleted, serviceName); }