C# 更改WCF连接中ChannelFactory的IPEndpoint

C# 更改WCF连接中ChannelFactory的IPEndpoint,c#,asp.net,.net,wcf,C#,Asp.net,.net,Wcf,是否可以使用ServicePoint将客户端的传出ip地址更改为WCF服务 var localIpAddress = IPAddress.Parse("192.168.1.113"); ServicePoint servicePoint = ServicePointManager.FindServicePoint(new Uri(oDataSource.wcfURL)); servicePoint.BindIPEndPointDelegate = (sp, rm,

是否可以使用ServicePoint将客户端的传出ip地址更改为WCF服务

var localIpAddress = IPAddress.Parse("192.168.1.113");
ServicePoint servicePoint = ServicePointManager.FindServicePoint(new Uri(oDataSource.wcfURL));
servicePoint.BindIPEndPointDelegate =
                (sp, rm, retryCount) =>
                {
                    //Console.WriteLine(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);
var localIpAddress=IPAddress.Parse(“192.168.1.113”);
ServicePoint ServicePoint=ServicePointManager.FindServicePoint(新Uri(oDataSource.wcfURL));
servicePoint.BindIPEndPointDelegate=
(sp、rm、retryCount)=>
{
//控制台写入线(retryCount);
返回新的IPEndPoint(localIpAddress,80);
};
DuplexChannelFactory oChannelFactory=新的DuplexChannelFactory(新的InstanceContext(this)、oBinding、oEndpoint);
oPubSubClient=oChannelFactory.CreateChannel();
oPubSubClient.Faulted+=新的事件处理程序(WcfFaultedListener);
oPubSubClient.Opened+=新事件处理程序(WcfOpenListener);

我试着使用上面的代码,但不起作用。调用oChannelFactory.CreateChannel()后,BindIPEndpointDelegate似乎进入了无止境循环。

它尝试绑定失败,直到int.MaxValue

如果您不能选择本地端点,只需返回null,就会自动为您选择一个端点


这里有一个

它试图绑定到int.MaxValue之前都没有成功

如果您不能选择本地端点,只需返回null,就会自动为您选择一个端点

这是