我正在以编程方式创建一个命名管道WCF服务和客户端。为什么“在配置元素集合中找不到与键匹配的元素”?
服务代码执行:
serviceHost = new ServiceHost(typeof(CFCAccessPointService), new Uri(Names.Address));
serviceHost.AddServiceEndpoint(typeof (ICfcAccessPoint), new NetNamedPipeBinding(Names.Binding), Names.Contract);
serviceHost.Open();
客户端代码:
var ctx = new InstanceContext(new StatusHandler());
s_proxy = new DuplexChannelFactory<ICfcAccessPoint>(ctx, new NetNamedPipeBinding(Names.Binding), new EndpointAddress(Names.Address));
与
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";
}
,以确保客户端和服务保持不变。
但是,如果我删除Names.Binding,以便没有指定绑定配置,则会出现在端点上找不到侦听器的错误。如果我包含它,我会得到“在配置元素集合中找不到与密钥匹配的元素”...
我没有使用.config文件。
还缺什么?
对不起,但没有任何建议工作。当我修改代码来设置安全模式时,我得到了无听者错误。添加配置文件完全没有区别。 – shipr