gpt4 book ai didi

c# - 如何在 WCF 中使用 net.Pipe 绑定(bind)

转载 作者:行者123 更新时间:2023-11-30 15:41:08 25 4
gpt4 key购买 nike

我有一个使用 Wcf 服务的项目。在我的 web.config 中绑定(bind)是:

<netNamedPipeBinding>
<binding name="RCISPNetNamedPipeBinding" />
</netNamedPipeBinding>

<service behaviorConfiguration="Fara.WcfServiceBehaviour" name="Fara.WcfService.CommonWcfService">
<endpoint address="CommonServices" binding="netNamedPipeBinding" bindingConfiguration="FaraNetNamedPipeBinding" contract="Fara.Common.ServiceContract.ICommonService" />
</service>

当我想创建服务主机时出现运行时错误

public class ServiceFactory : ServiceHostFactory
{
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
{
if (!IsInitialised) InitialiseService();
return base.CreateServiceHost(serviceType, baseAddresses);
}

}

异常信息是:

找不到与具有绑定(bind) NetNamedPipeBinding 的端点的方案 net.pipe 相匹配的基地址。注册的基址方案是 [http].

我的项目的属性是: enter image description here

我该如何纠正这个错误?

我更新了 Web.config : 但是我的问题没有解决!

enter image description here enter image description here enter image description here

最佳答案

正如错误消息所说的非常清楚:您没有为 net.pipe 绑定(bind)定义任何基地址。所以定义一个!

<service name="Fara.WcfService.CommonWcfService"
behaviorConfiguration="Fara.WcfServiceBehaviour" >
<host>
<baseAddresses>
<add baseAddress="net.pipe://localhost/Services" />
</baseAddresses>
</host>
<endpoint
address="CommonServices"
binding="netNamedPipeBinding" bindingConfiguration="FaraNetNamedPipeBinding"
contract="Fara.Common.ServiceContract.ICommonService" />
</service>

那么您的服务端点将是 net.pipe://localhost/Services/CommonServices

关于c# - 如何在 WCF 中使用 net.Pipe 绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8667311/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com