使用最新的monotouch(4.0.3),我们可以调用WCF服务。执行完呼叫后,第10次尝试崩溃。我创建了一个测试程序,调用简单的WCF调用来查看服务是否已启动。回复OK消息。 10号召唤它失败了。尝试服务器配置设置,关闭,在客户端上处置仍然相同的结果。示例测试代码段如下:
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
mailButton.TouchUpInside += (o, e) =>
{
BasicHttpBinding BindType = new BasicHttpBinding();
BindType.ReceiveTimeout = new TimeSpan(0,0,15);
EndpointAddress ep = new EndpointAddress(@"http://myservice.mydomain.com/MyBusServiceBusService/MFService.svc/BaseService");
BaseServiceClient MFService = new BaseServiceClient(BindType, ep);
MFService.Endpoint.Binding.ReceiveTimeout = new TimeSpan(0,0,10);
MFService.BaseServiceTestCompleted += delegate(object sender, BaseServiceTestCompletedEventArgs ex)
{
UIAlertView alert = new UIAlertView();
alert.Title = "Base Service Test";
alert.AddButton("Ok");
++timesThrough;
alert.Message = ex.Result + " Times=" + timesThrough.ToString();;
alert.InvokeOnMainThread(delegate{alert.Show(); });
var clientObject = sender as BaseServiceClient;
if (clientObject != null && clientObject.State == System.ServiceModel.CommunicationState.Opened)
{
(clientObject.ChannelFactory).Close();
(clientObject).Close();
((IDisposable)clientObject).Dispose();
clientObject = null;
}
if (MFService != null)
{
(MFService.ChannelFactory).Close();
(MFService).Close();
((IDisposable)MFService).Dispose();
MFService = null;
}
GC.Collect();
};
try
{
MFService.BaseServiceTestAsync();
}
catch (Exception ex)
{
UIAlertView alert = new UIAlertView();
alert.Title = "Base Service Test";
alert.AddButton("Ok");
alert.Message = ex.Message ;
alert.InvokeOnMainThread(delegate{alert.Show();});
MFService = null;
GC.Collect();
}
};
}
答案 0 :(得分:0)
此问题已在最新的MonoTouch(4.1测试版)中修复。 4.2(稳定)版本应尽快推出。