zoukankan      html  css  js  c++  java
  • 配置MaxReceivedMessageSize解决:System.ServiceModel.QuotaExceededException: 已超过传入消息(65536)的最大消息大小配额。

    System.ServiceModel.CommunicationException: 已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性。 ---> System.ServiceModel.QuotaExceededException: 已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性。  

    --- 内部异常堆栈跟踪的结尾 ---
    Server stack trace:    在 System.ServiceModel.Channels.MessageEncoder.BufferMessageStream(Stream stream, BufferManager bufferManager, Int32 maxBufferSize)   在 System.ServiceModel.Channels.MessageEncoder.ReadMessage(Stream stream, BufferManager bufferManager, Int32 maxBufferSize, String contentType)   在 System.ServiceModel.Channels.HttpInput.ReadChunkedBufferedMessage(Stream inputStream)  

    在 System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(Exception& requestException)  在 System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)   在 System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)   在 System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)   在 System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)   在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)   在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    …………

    解决办法:设置客户端的MaxReceivedMessageSize等属性值即可,代码设置如下:

    ServiceClient service = new ServiceClient();

    (service.Endpoint.Binding
    as NetTcpBinding).MaxReceivedMessageSize = int.MaxValue;
    (service.Endpoint.Binding
    as NetTcpBinding).MaxBufferPoolSize = int.MaxValue;
    (service.Endpoint.Binding
    as NetTcpBinding).MaxBufferSize = int.MaxValue;

    也可以在配置文件中(app.config/web.config)设置如下代码:

    

    只要maxReceivedMessageSize大于返回的量即可。

  • 相关阅读:
    css实现强制不换行/自动换行/强制换行
    JavaScript模仿语言包式的简繁转换功能插件
    全国DNS服务器IP地址【电信、网通、铁通】
    删除隐藏网卡(本机IP地址被占用)4个方法
    javascript自定义insertAfter()函数
    HTTP协议header头域
    使用css模拟vista毛玻璃效果
    GRUB4DOS加载ISO启动光盘完美解决方案
    javascript在IE和Firefox中兼容性问题
    XML格式的字符串与DataSet之间的转换
  • 原文地址:https://www.cnblogs.com/blackcore/p/1984660.html
Copyright © 2011-2022 走看看