views:

300

answers:

1

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?

+3  A: 

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.

Furis
Perfect. Thanks very much