How to increase maxReceivedMessageSize and maxBufferSize parameters in app.config file to 2000000 before running the application.
You need to do that on your binding, but you'll need to do it on both Client and Server. Something like:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding maxBufferSize="64000000" maxReceivedMessageSize="64000000" />
</basicHttpBinding>
</bindings>
</system.serviceModel>
You can do that in your app.config. like that:
maxReceivedMessageSize="2147483647"
(The max value is Int32.MaxValue
)
Or in Code:
WSHttpBinding binding = new WSHttpBinding();
binding.Name = "MyBinding";
binding.MaxReceivedMessageSize = Int32.MaxValue;
Note:
If your service is open to the Wide world, think about security when you increase this value.
If you are using a custom binding, you can set the values like this:
<customBinding>
<binding name="x">
<httpsTransport maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
</binding>
</customBinding>
Open app.config on client side and add maxBufferSize and maxReceivedMessageSize attributes if it is not available
Original
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Service1Soap"/>
</basicHttpBinding>
</bindings>
After Edit/Update
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Service1Soap" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/>
</basicHttpBinding>
</bindings>
Easy solution: Check if it works for you..
Goto web.config
Find binding used by client.
change as,
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
Done.
The currently accepted answer is incorrect. It is NOT required to set maxBufferSize
and maxReceivedMessageSize
on the client and the server binding. It depends!
If your request is too large (i.e., method parameters of the service operation are memory intensive) set the properties on the server-side, if the response is too large (i.e., the method return value of the service operation is memory intensive) set the values on the client-side.
For the difference between maxBufferSize
and maxReceivedMessageSize
see MaxBufferSize property?.