Esempio n. 1
0
        void SendExecuteMessage(IEnumerable <GuidData> applicationInstances, string command)
        {
            List <Exception> exceptions = null;

            foreach (GuidData applicationInstanceId in applicationInstances)
            {
                try {
                    using (ChannelFactory <IApplicationInstance> pipeFactory = new ChannelFactory <IApplicationInstance>(new NetNamedPipeBinding(), new EndpointAddress(string.Format("{0}/{1}", GetServiceUri(applicationInstanceId), EndPointName)))) {
                        IApplicationInstance pipeProxy = pipeFactory.CreateChannel();
                        pipeProxy.Execute(command);
                    }
                } catch (CommunicationException) {
                } catch (Exception e) {
                    if (exceptions == null)
                    {
                        exceptions = new List <Exception>();
                    }
                    exceptions.Add(e);
                }
            }
            if (exceptions != null)
            {
                throw new InvalidOperationException("", new AggregateException(exceptions.ToArray()));
            }
        }