我正在使用Visual Studio创建的WCF服务。

我正在执行诸如GetDataAsync(param)之类的调用来检索数据。在GetDataCompleted处理程序中,我正在使用检索到的数据。

该服务有效。有时我无法检索数据。在这种情况下,将发生如下异常:

Exception in async operation: System.Net.ProtocolViolationException: The number of bytes to be written is greater than the specified ContentLength.
  at System.Net.WebConnectionStream.CheckWriteOverflow (Int64 contentLength, Int64 totalWritten, Int64 size) [0x00038] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebConnectionStream.cs:546

怎么可能遇到类似的情况?该应用程序仍在运行,但在控制台上打印了异常。我认为异常(exception)来自Channel或其他原因。

先感谢您。

最佳答案

不幸的是,目前在Monotouch中无法捕获这些WCF异常。这似乎是一个已知的错误。参见MonoTouch - WCF Services made by Silverlight tool - Can't catch exceptions

关于wcf - Monotouch : WCF services and Exception handling,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5486746/

10-12 05:08