C# WCF中的ServicePoint无法绑定IP

C# WCF中的ServicePoint无法绑定IP,c#,asp.net,.net,wcf,networking,C#,Asp.net,.net,Wcf,Networking,我有以下代码 WSDualHttpBinding oBinding = new WSDualHttpBinding(); oBinding.Security.Mode = WSDualHttpSecurityMode.None; oBinding.Security.Message.ClientCredentialType = System.ServiceModel.MessageCredentialType.None; o

我有以下代码

 WSDualHttpBinding oBinding = new WSDualHttpBinding();
            oBinding.Security.Mode = WSDualHttpSecurityMode.None;
            oBinding.Security.Message.ClientCredentialType = System.ServiceModel.MessageCredentialType.None;
            oBinding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default;

            oBinding.ReceiveTimeout = new TimeSpan(0, 30, 0);
            oBinding.ReliableSession.Ordered = true;
            oBinding.ReliableSession.InactivityTimeout = new TimeSpan(0, 0, 7);

            EndpointAddress oEndpoint = new EndpointAddress(oDataSource.wcfURL);

            var localIpAddress = IPAddress.Parse("192.168.1.121");
            ServicePoint servicePoint = ServicePointManager.FindServicePoint(new Uri(oDataSource.wcfURL));
            servicePoint.BindIPEndPointDelegate =
                            (sp, rm, retryCount) =>
                            {
                                return new IPEndPoint(localIpAddress, 80);
                            };

            DuplexChannelFactory<IBSPubSubService> oChannelFactory = new DuplexChannelFactory<IBSPubSubService>(new InstanceContext(this), oBinding, oEndpoint);

            oPubSubClient = oChannelFactory.CreateChannel();
            oPubSubClient.Faulted += new EventHandler(WcfFaultedListener);
            oPubSubClient.Opened += new EventHandler(WcfOpenListener);
WSDualHttpBinding oBinding=newwsdualhttpbinding();
oBinding.Security.Mode=WSDualHttpSecurityMode.None;
oBinding.Security.Message.ClientCredentialType=System.ServiceModel.MessageCredentialType.None;
oBinding.Security.Message.AlgorithmSuite=System.ServiceModel.Security.SecurityAlgorithmSuite.Default;
oBinding.ReceiveTimeout=新的时间跨度(0,30,0);
oBinding.ReliableSession.Ordered=true;
oBinding.ReliableSession.InactivityTimeout=新的时间跨度(0,0,7);
EndpointAddress oEndpoint=新的EndpointAddress(oDataSource.wcfURL);
var localIpAddress=IPAddress.Parse(“192.168.1.121”);
ServicePoint ServicePoint=ServicePointManager.FindServicePoint(新Uri(oDataSource.wcfURL));
servicePoint.BindIPEndPointDelegate=
(sp、rm、retryCount)=>
{
返回新的IPEndPoint(localIpAddress,80);
};
DuplexChannelFactory oChannelFactory=新的DuplexChannelFactory(新的InstanceContext(this)、oBinding、oEndpoint);
oPubSubClient=oChannelFactory.CreateChannel();
oPubSubClient.Faulted+=新的事件处理程序(WcfFaultedListener);
oPubSubClient.Opened+=新事件处理程序(WcfOpenListener);

目标是使用特定的IP地址和端口连接到WCF服务。然而,当我尝试使用上面的代码时,似乎我无法再创建到wcf的通道。删除servicepoint可以工作,但如果没有它,我将无法选择在多个NIC的情况下要使用的特定IP。有人能帮我吗?

你想把
IP地址
作为
端点
,然后你需要创建
端点地址
,有关更多信息,请查看我正在尝试在多个NIC的情况下使用IP地址作为客户端的传出IP地址。是否尝试将该
IP地址
作为
端点
,然后需要创建
端点地址
,有关更多信息,请查看我正在尝试在多个NIC的情况下使用IP地址作为客户端的传出IP地址。