Monotouch / WCF:为什么不能覆盖wcf绑定默认超时设置:
public class MyServiceClient : ClientBase<IMyContract>,IMyContract
{ ... }
public void test() {
BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
basicHttpBinding.Name = "basicHttpBinding";
basicHttpBinding.MaxBufferSize = int.MaxValue;
basicHttpBinding.MaxReceivedMessageSize = int.MaxValue;
basicHttpBinding.ReceiveTimeout = TimeSpan.FromSeconds(10.0);
basicHttpBinding.SendTimeout = TimeSpan.FromSeconds(10.0);
basicHttpBinding.CloseTimeout = TimeSpan.FromSeconds(5.0);
basicHttpBinding.OpenTimeout = TimeSpan.FromSeconds(5.0);
MyServiceClient client = New MyServiceClient(basicHttpBinding, new EndPointAddress(...));
client.Test();
}
//虽然我将OpenTimeout设置为5秒,但是当我关闭服务器服务(或关闭iphone的wifi和网络)时,它仍然尝试在后台连接到服务,直到默认的1 miniute超时,真奇怪!为什么?感谢。
顺便说一句,monotouch / iPhone中的异常在1分钟后抛出,类型是TimeoutException(消息:操作已经超时。)不是FaultException或CommunicationException)。如果上面的代码在windows .net客户端中调用,则应该抛出CommunicationException。答案 0 :(得分:8)
xamarin团队回复:serviceClient.innerchannel.operationtimeout = ... 谢谢。