配置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)设置如下代码:

2011031511453115.jpg

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

转载于:https://www.cnblogs.com/blackcore/archive/2011/03/15/1984660.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值