我有一个WCF服务,我的客户端是一个Silverlight应用程序 . 当服务中断(网络错误等)时,我在客户端代理上得到此异常:
CommunicationException:通信对象System.ServiceModel.Channels.ClientFramingDuplexSessionChannel不能用于通信,因为它处于Faulted状态 .
准确地说,在下面的代码的第5行:
public System.IAsyncResult BeginPublishVideo(byte[] data, System.AsyncCallback callback, object asyncState) {
object[] _args = new object[1];
_args[0] = data;
//Below is when the exception is received
System.IAsyncResult _result = base.BeginInvoke("PublishVideo", _args, callback, asyncState);
return _result;
}
所以我尝试在try / catch中包装服务调用(来自堆栈跟踪),但无济于事,try / catch不会被执行 . 基本上这个:
try
{
_videoClient.PublishVideoAsync(codedVideoBuffer);
}
catch (Exception) { }
但尝试捕获永远不会受到打击 . 我怎样才能捕获这个异常并优雅地处理它?
TIA .