Share via


Data Size limit causing Silverlight "Not Found" error when communicating with backend WCF Service

Issue: when data size exceeds a limit (e.g. 50000Bytes), Silverlight application throw "NotFound" error when communicating with WCF service at backend

Troubleshooting Tips: The symptom tells us the issue is due to a limit between Silverlight and WCF Service. But there are many limits set, what could be the one we need to increase for this case?
In order to understand what limit we hit here, we will need to capture first chance exception on server side - use DebugDiag and configure debug rule to capture all exceptions
with exception code is E0434352 for the w3wp.exe instance that hosts the WCF Service. After memory dump taken, open it in windbg and check the exception object in the call stack that throws the exception.

In this particular case, Service side throw exception in memory dumps captured by DebugDiag:

System.ServiceModel.ProtocolException: MaxReceivedMessageSizeExceeded

Detailed message:
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.

With the exception message, we know it is MaxReceivedMessageSize needs to be increased for this scenario.

Below is the minimum servicemodel configuration needed in the service side web.config.
“maxReceivedMessageSize” and “readerQuotas maxArrayLength” are the only two required to increase the limit in this issue.

In crease the limits by the following configuration on service and client sides.

On service side:

<system.serviceModel>
...
      <bindings>
      <basicHttpBinding>
        <binding name="basicHttpBinding" maxReceivedMessageSize="5000000">
          <readerQuotas maxArrayLength="5000000" />
        </binding>
      </basicHttpBinding>
    </bindings>
...    
</system.serviceModel>

On the client side configuration (ServiceReferences.ClientConfig), it should be as below:

<system.serviceModel>
...
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_YourService" maxBufferSize="5000000" maxReceivedMessageSize="5000000">
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>
...
</system.serviceModel>