简体   繁体   English

找不到WCF命名管道端点

[英]WCF Named Pipes Endpoint not found

In a simple way, we need to do outproc communications through WCF named pipes. 以简单的方式,我们需要通过WCF命名管道进行外向通信。 In the dev harness the applications both client and service components are instantiated through IOC in the same executable. 在开发工具中,客户端和服务组件都通过IOC在同一可执行文件中实例化。

Service host: 服务主机:

/// <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();
}

Client: 客户:

/// <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))))
{

}

Both of which are constructed successfully but when the client calls the service it generates this error: 两者均已成功构建,但是当客户端调用服务时,它将生成此错误:

There was no endpoint listening at net.pipe://localhost/opa/runtime that could accept the message. 在net.pipe:// localhost / opa / runtime上没有侦听终结点的端点可以接受该消息。 This is often caused by an incorrect address or SOAP action. 这通常是由不正确的地址或SOAP操作引起的。 See InnerException, if present, for more details. 有关更多详细信息,请参见InnerException(如果存在)。

Unfortunately there's no inner exception. 不幸的是,没有内在的例外。 As per other questions I made sure the Net.Pipe Listener service is running. 根据其他问题,我确保Net.Pipe Listener服务正在运行。 Visual Studio is running with elevated priviledges. Visual Studio以提升的特权运行。

Environments are VS2015 on Windows 10 or VS2012 on Windows 7. 环境是Windows 10上的VS2015或Windows 7上的VS2012。

Am I missing anything? 我有什么想念的吗?

I believe the call to AddServiceEndpoint needs the address of the endpoint (according to the MSDN documentation ). 我相信对AddServiceEndpoint的调用需要端点的地址(根据MSDN文档 )。 In your example code, it looks like you are only passing the serviceName. 在示例代码中,您似乎只传递了serviceName。

I dug up some example code that is doing something similar. 我挖出了一些类似的示例代码。 However, in my example, I am deriving from ServiceHost: 但是,在我的示例中,我源自ServiceHost:

public class CustomServiceHost : ServiceHost
{
    public CustomServiceHost() : base(
        new CustomService(),
        new[] { new Uri(string.Format("net.pipe://localhost/{0}", typeof(ICustomService).FullName)) })
    {

    }

    protected override void ApplyConfiguration()
    {
        base.ApplyConfiguration();

        foreach (var baseAddress in BaseAddresses)
        {
            AddServiceEndpoint(typeof(ICustomService), new NetNamedPipeBinding(), baseAddress);
        }
    }
}

Got it figured out. 明白了。 Service name was used twice in the service host setup therefore make something like net.pipe://localhost/opa/runtime/runtime when it should have contained this: net.pipe://localhost/opa/runtime. 服务名称在服务主机设置中使用了两次,因此应在其中包含net.pipe:// localhost / opa / runtime / runtime之类的名称:net.pipe:// localhost / opa / runtime。 Thanks for the rubber duckie. 谢谢你的橡皮鸭。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM