Wcf – Maximum Message Size quota for Incoming messages has been exceeded exception

wcf

I increased the MaxReceivedMessageSize to 2147483647 but I still get this error. I put the same value on the server config and client config. Please helpppp

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.

Best Solution

If you've set the values in the <binding> section of your config file, you need to make sure you reference those bindings in the bindingConfiguration attribute of the <endpoint> element:

I.e.,:

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

Obviously this is not a complete config file, it's merely a visual demonstration of the relationship between the <endpoint> bindingConfiguration attribute and the <binding> name attribute. If you don't set this, WCF will give you a binding with the default values.

Related Question