I am trying to create multiple instances of the same WCF server (NetNamedPipes) (starting application several times) but running into a problem on starting the second instance... The server instances are using different pipe names and endpoint names. I used the example from here, only setting the endpoint and pipe name via start up arguments. But on the second instance, I get an error message that there is a faulty state and therefore the servicehost cannot be opened.
Using Http binding with different ports works, but I would like to stick with named pipes.
Server:
[ServiceContract]
public interface IServiceContract
{
[OperationContract]
string Operation(string value);
}
class Program : IServiceContract
{
static void Main(string[] args)
{
Console.WriteLine($"Pipe: {args[0]}");
Console.WriteLine($"Endpoint: {args[1]}");
ServiceHost sh = new ServiceHost(typeof(Program), new Uri($"net.pipe://{args[0]}"));
sh.AddServiceEndpoint(typeof(IServiceContract), new NetNamedPipeBinding(), args[1]);
sh.Open();
Console.ReadLine();
}
public string Operation(string value)
{
return value.ToUpper();
}
}
Error message: AddressAlreadyInUseException
because a different endpoint is already listening to this endpoint.