RESULT: Stupid mistake by yours truly. Adding my client to the service's Dictionary incorrectly was causing the fault. I was looking for the problem in all the wrong places.
I have a named pipe WCF service with a callback. It reports USB device plug in events to clients. The problem I have is that if I quit the client and restart it, I always get a channel fault. When I exit the client I call code as follows:
public void Dispose()
{
try
{
if (factory.State == CommunicationState.Opened)
{
proxy.UnSubscribe(_clientName);
factory.Close();
}
else
{
factory.Abort();
}
}
catch (Exception)
{
factory.Abort();
}
}
I create the channel as follows:
NetNamedPipeBinding netPipe = new NetNamedPipeBinding();
// Security is not worth it for this.
netPipe.Security.Mode = NetNamedPipeSecurityMode.None;
// The receive time on the client side is ignored. The time the callback session
// is kept alive is determined by the receive time on the service side which is infinite.
factory = new DuplexChannelFactory<IUsbBroker>(
new InstanceContext(this), netPipe,
new EndpointAddress("net.pipe://localhost/Gyannea/WCFCallbacks/UsbBroker"));
try
{
proxy = (IUsbBroker)factory.CreateChannel();
}
catch (Exception)
{
factory.Abort();
}
I newly added the try-catch in the channel/proxy creation to see if that was the problem when I restarted the client in attempt to try and recreate the channel again if it was faulted after aborting. It did not work.
Am I missing something fundamental here? Thanks!