0

I've got a WCF server/client setup using named pipes, and my client connects to the host process (already running) as follows:

var pipeFactory = new DuplexChannelFactory<IArbiter>(this, new NetNamedPipeBinding(), new EndpointAddress(new Uri("net.pipe://localhost/IArbiter")));
arbiter = pipeFactory.CreateChannel();

This is fine for the first client connecting, but when the second client connects, a new instance of the IArbiter implementation is created (the arbiter's constructor is called every time a connection happens).

Is there a way to find the "existing" instance of that arbiter at the endpoint address?

odkken
  • 329
  • 1
  • 9
  • That is the default behavior of WCF - each request gets its own instance of the service class. And I personally would leave it that way - it's the easiest and most scalable way of running your WCF service. Why is that a problem for you? – marc_s Aug 23 '14 at 07:35
  • Because the arbiter class is intended to channel multiple WCF clients into one tcp/ip message interface. I suppose I can just implement it as a singleton. – odkken Aug 25 '14 at 16:34

1 Answers1

0

Figured it out, just need to set this above my class implementation:

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
odkken
  • 329
  • 1
  • 9