WCF and DataSet? Use maxReceivedMessageSize
Today I tried to figure why the following code stucks:
using(MyServiceProxy proxy = new MyServiceProxy())
using (OperationContextScope scope =
myDataSet = proxy.GetData(filter);
While debugging the WCF and DataSet sample, the debug never passed the final curly bracket ("}").
Digging more into it, I found out that when the called operation returns an empty DataSet or a small-size DataSet, it all worked fine.
When I placed the break-point just before that final curly bracket, I noticed that the debugger reaches it, but never passes.
After digging some more, I realized that there is a default maximum message size of 65536 bytes. When the filled DataSet exceeded this size limit, the call never ended.
The idea behind this limit is to limit the exposure to denial of service. Using the limit of 65536 bytes, WCF Only allocates this static size of memory for each message. Then, if in incoming message is larger than that size, the message is dropped.
To change the default maxReceivedMessageSize, set that attribute in the binding configuration, as shown here: