传入消息的最大消息大小配额已超出异常。

4

我将MaxReceivedMessageSize增加到2147483647,但仍然出现错误。我在服务器配置和客户端配置上都放置了相同的值。请帮助解决这个问题。

The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

Server stack trace: 
   at System.ServiceModel.Channels.HttpInput.ThrowMaxReceivedMessageSizeExceeded()
   at System.ServiceModel.Channels.HttpInput.GetMessageBuffer()
   at System.ServiceModel.Channels.HttpInput.ReadBufferedMessage(Stream inputStream)
   at System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(Exception& requestException)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at IService1.GetRecordsforMAR(Int32 showDeleted)
   at Service1Client.GetRecordsforMAR(Int32 showDeleted)

Inner Exception:
The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

由于您仍然在下限处遇到错误,说明您没有在正确的位置更改值:“...在适当的绑定元素上。” - Marc B
我已经更改了客户端和服务器配置文件中的值。我不确定还需要在哪里进行更改。我是WCF的新手,请帮忙。 - user787951
如果您需要更多帮助,您就必须发布 XML。 - ErnieL
1个回答

4
如果您在配置文件的``部分中设置了值,则需要确保在``元素的`bindingConfiguration`属性中引用这些绑定。例如:
<bindings>
    <wsHttpBinding>
        <binding name="MyWsHttpBinding" /> 
        <!-- Other values for this binding ommitted for purposes of demonstration -->
    </wsHttpBinding>
</bindings>

<services>
    <service name=MyService">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="MyWsHttpBinding" contract="IMyContract" />
    <service>
</services>

显然,这不是一个完整的配置文件,仅仅是展示 <endpoint> bindingConfiguration 属性和 <binding> name 属性之间关系的视觉演示。如果你不设置这个,WCF会给你一个使用默认值的绑定。


谢谢,只想补充一下,这些更改应该在服务器和客户端上都应用才能使其正常工作(这些设置是maxBufferPoolSize和maxReceivedMessageSize)。 - Anvar

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接