I have two applications that exposes WCF endpoints using named pipes for communication.
One app is a WPF user application and the other one is a Windows Service, when I make a call from the user app to the win service it's fine, but whenever the Windows Service calls the WPF's application endpoint I receive an System.ServiceModel.CommunicationObjectFaultedException stating that the Communication Object cannot be used while it's in faulted exception.
The funny thing is that if I copy and paste my code to a Console Application it works just fine.
Here is the code I'm using to create the communication object
public void CallService()
{
using (var channel = GetServiceClient())
{
channel.Open();
var service = channel.CreateChannel();
service.DoFoo();
}
}
private static ChannelFactory<IFooService> GetServiceClient()
{
return new ChannelFactory<IFooService>(
new NetNamedPipeBinding
{
Security = new NetNamedPipeSecurity { Mode = NetNamedPipeSecurityMode.None }
},
@"net.pipe://barAddress/fooService");
}