I am programmatically creating a named pipe WCF service and client.
The service code does:
serviceHost = new ServiceHost(typeof(CFCAccessPointService), new Uri(Names.Address));
serviceHost.AddServiceEndpoint(typeof (ICfcAccessPoint), new NetNamedPipeBinding(Names.Binding), Names.Contract);
serviceHost.Open();
The client code:
var ctx = new InstanceContext(new StatusHandler());
s_proxy = new DuplexChannelFactory<ICfcAccessPoint>(ctx, new NetNamedPipeBinding(Names.Binding), new EndpointAddress(Names.Address));
with
public static class Names
{
public const string Address = "net.pipe://localhost/CFC/Plugins/GuestAccessService";
public const string Binding = "netNamedPipeBinding_ICfcAccessPoint";
public const string Contract = "GuestAccessClientServerInterface.ICfcAccessPoint";
}
to ensure the client and service stay the same.
But if I drop the Names.Binding so that no binding configuration is specified, I get the error that no listener could be found at the endpoint. If I include it, I get "no elements matching the key were found in the configuration element collection"...
I am not using .config files.
What is still missing?
The binding was fine, either way, and in fact needed no argument at all.
The trouble was with the contract. When I changed to code to:
public static class Names
{
public const string Address = "net.pipe://localhost/CFC/Plugins/GuestAccessService/";
public const string Binding = "";
public const string Contract = "CfcAccessPoint";
}
and on the service side:
this.serviceHost.AddServiceEndpoint(typeof(ICfcAccessPoint), new NetNamedPipeBinding(), Names.Contract);
and on the client side:
var ctx = new InstanceContext(this);
proxy = new DuplexChannelFactory<ICfcAccessPoint>(ctx, new NetNamedPipeBinding(), new EndpointAddress(Names.Address) + Names.Contract);
then things worked fine. The service just names the pipe; the client adds the address to the pipe name.
Voilá!