8

We have a .NET program that uses WCF to listen for communication from another process. We used named pipes.

ServiceHost host = new ServiceHost(
  typeof(Something),
  new Uri[]
    {
        new Uri("net.pipe://localhost")
    });
host.AddServiceEndpoint(typeof(ISomething), new NetNamedPipeBinding(), "Something");
host.Open();

The code worked great until a third party .NET program was installed. Now the open fails with a message of "Cannot listen on pipe name 'net.pipe://localhost/' because another pipe endpoint is already listening on that name."

My assumption is that the other program is already using named pipes. Is there a workaround or can only one program on a computer use named pipes? I get the impression from other questions that you can set a "name" for a pipe so it doens't conflict with other processes, how do you do that?

  • 1
    Can use Handle.exe from [SysInternals](http://technet.microsoft.com/en-us/sysinternals/default.aspx) to find out what application is using currently using your named pipe. Command "Handle.exe net.pipe:". See [Rodney Viana's post](http://blogs.msdn.com/b/rodneyviana/archive/2011/03/22/named-pipes-in-wcf-are-named-but-not-by-you-and-how-to-find-the-actual-windows-object-name.aspx) – mcdon Dec 04 '13 at 15:52

1 Answers1

15

You can use multiple named pipes at a time. Take a look at Juval Lowy's ServiceModelEx from his book Programming WCF Services. You will see when he creates named pipes, he uses code that looks something like:

Uri baseAddress = new Uri("net.pipe://localhost/" + Guid.NewGuid().ToString());

Which should avoid name conflicts.

makerofthings7
  • 60,103
  • 53
  • 215
  • 448
AshtonKJ
  • 1,376
  • 2
  • 14
  • 22