public bool AddRemoteInstance(ServiceControlInstance instance, string[] remoteInstanceAddresses, ILogging log) { if (Compatibility.RemoteInstancesDoNotNeedQueueAddress.SupportedFrom > instance.Version) { log.Error($"Cannot add remote instances to instances older than {Compatibility.RemoteInstancesDoNotNeedQueueAddress.SupportedFrom}"); return(false); } instance.ReportCard = new ReportCard(); var restartService = instance.Service.Status == ServiceControllerStatus.Running; if (!instance.TryStopService()) { logger.Error("Service failed to stop or service stop timed out"); } try { foreach (var remoteInstanceAddress in remoteInstanceAddresses) { instance.AddRemoteInstance(remoteInstanceAddress); } instance.ApplyConfigChange(); if (restartService && !instance.TryStartService()) { logger.Error("Service failed to start after adding remote instances - please check configuration for {0}", instance.Name); return(false); } } catch (Exception ex) { logger.Error("Adding remote instances Failed: {0}", ex.Message); return(false); } return(true); }