当数据库结果非常好时,我如何处理WCF服务

本文关键字:处理 服务 WCF 何处理 结果 数据库 非常好 | 更新日期: 2023-09-27 18:10:08

我使用下面的代码:

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;
        }
    }

当查询返回大量结果时我遇到这样的消息:

通信对象不能用于通信,因为它处于fault状态

确实存在一种方法或技巧,我可以成功地观察数据库查询的结果或者我把结果除以或者得到结果的一部分的方法?

当数据库结果非常好时,我如何处理WCF服务

您可能需要放大maxReceivedMessageSize,或其他绑定参数之一。

您也可以启用wcf跟踪并使用svcTraceViewer.exe查看

你会得到这样的错误:

通信对象不能用于通信,因为它故障状态

,因为你抛出了一个错误,它没有被处理,被抛出在iis池

查看此链接:http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/fc60cd6d-1df9-47ff-90a8-dd8d5de1f080/这也不是由大量数据引起的:WCF不能用于通信,因为它处于故障状态