【发布时间】:2016-01-04 17:51:32
【问题描述】:
简单来说,我们需要通过 WCF 命名管道进行 outproc 通信。在开发工具中,客户端和服务组件都通过 IOC 在同一个可执行文件中实例化。
服务主机:
/// <summary>
/// Default constructor
/// </summary>
public OpaRuntimeServiceHost(string serviceName, string hostAddress)
{
_serviceHost = new ServiceHost(typeof(OpaRuntimeService), new Uri[] {
new Uri(string.Format("net.pipe://{0}/opa/{1}", hostAddress, serviceName))
});
_serviceHost.AddServiceEndpoint(typeof(IOpaRuntimeService), new NetNamedPipeBinding(NetNamedPipeSecurityMode.None), serviceName);
_serviceHost.Open();
}
客户:
/// <summary>
/// Default constructor
/// </summary>
/// <param name="hostAddress"></param>
/// <param name="serviceName"></param>
public OpaRuntimeServiceClient(string serviceName, string hostAddress)
: base(new ServiceEndpoint(ContractDescription.GetContract(typeof(IOpaRuntimeService)),
new NetNamedPipeBinding(NetNamedPipeSecurityMode.None), new EndpointAddress(string.Format("net.pipe://{0}/opa/{1}", hostAddress, serviceName))))
{
}
两者都构造成功,但是当客户端调用服务时会产生这个错误:
在 net.pipe://localhost/opa/runtime 上没有可以接受消息的端点侦听。这通常是由不正确的地址或 SOAP 操作引起的。有关详细信息,请参阅 InnerException(如果存在)。
不幸的是,没有内在的例外。根据其他问题,我确保 Net.Pipe Listener 服务正在运行。 Visual Studio 以提升的权限运行。
环境是 Windows 10 上的 VS2015 或 Windows 7 上的 VS2012。
我错过了什么吗?
【问题讨论】:
标签: c# wcf named-pipes