views:

14

answers:

0

I have a WCF service which uses the named pipe binding. In one part of my code I want to restart this service, so I simply run

serviceHost.Close();
serviceHost = new ServiceHost(singletonInstance, uri);
serviceHost.Open();

For some reason, the Open call sometimes gives an exception:

Cannot listen on pipe name 'net.pipe://localhost/' because another pipe endpoint is already listening on that name.
at System.ServiceModel.Channels.PipeConnectionListener.Listen()
at System.ServiceModel.Channels.BufferedConnectionListener.Listen()
at System.ServiceModel.Channels.ExclusiveNamedPipeTransportManager.OnOpen()
at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
at System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback)
at System.ServiceModel.Channels.TransportChannelListener.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.ConnectionOrientedTransportChannelListener.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.NamedPipeChannelListener`2.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)

Why would the name be busy if I've just closed the service host?

related questions