我使用以下代码:
private class WcfProxy<TService> :
ClientBase<TService> where TService : class, IContract
{
public TService WcfChannel
{
get
{
return Channel;
}
}
}
protected TResult ExecuteCommand<TResult>(Func<TContract, TResult> command)
where TResult : IDtoResponseEnvelop
{
var proxy = new WcfProxy<TContract>();
try
{
var result = command.Invoke(proxy.WcfChannel);
proxy.Close();
return result;
}
catch (CommunicationException ex)
{
proxy.Abort();
throw new BusinessException(BusinessExceptionEnum.Operational, Properties.Resources.Exception.WcfAdapterBase_CommunicationException_TransportInEnamDataIsInvalid, ex);
}
catch (TimeoutException ex)
{
proxy.Abort();
throw new BusinessException(BusinessExceptionEnum.Operational, Properties.Resources.Exception.WcfAdapterBase_TimeoutException, ex);
}
catch (Exception)
{
proxy.Abort();
throw;
}
}
当查询返回大量结果时 我遇到这条消息:
通信对象不能用于通信,因为它处于故障状态
确实存在一种方法或技巧,我成功地观察了数据库查询的结果 或者我将结果分开或得到结果的一部分的方式?
答案 0 :(得分:1)
您可能需要放大maxReceivedMessageSize或其他绑定参数之一。
您还可以启用wcf跟踪并使用svcTraceViewer.exe
进行查看答案 1 :(得分:0)
您收到此错误:
通信对象不能用于通信,因为它 处于Faulted状态。
因为你抛出一个错误并且没有处理它并被抛入 iis pool 。
检查此链接:http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/fc60cd6d-1df9-47ff-90a8-dd8d5de1f080/这也不是由大量数据引起的:WCF Cannot be used for communication because it is in the Faulted state