WCF Service – MaxReceivedMessageSize Error

wcf

I have my WCF Service hosted in Windows Service. The client application is a website project to which I add Service reference.

Now, Windows Service configuration file has the right settings for MaxReceivedMessageSize:

  <netTcpBinding>
    <binding name="netTcp" maxBufferPoolSize="50000000" maxReceivedMessageSize="50000000">
      <readerQuotas maxDepth="500" maxStringContentLength="50000000" maxArrayLength="50000000"
                    maxBytesPerRead="50000000" maxNameTableCharCount="50000000" />
      <security mode="None"></security>
    </binding>
  </netTcpBinding>

But when I add Service Reference to WebSite project, it updates the web.config with default values. And then I receive this error:
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.

I reckon, updating website config file with the settings in service congig will resolve this error.

But I wonder if I need to change these setting manually everytime I add service reference?

Best Answer

Yes unfortunately, when adding the Service Reference, the settings from the server will not be transmitted to the client. You'll have to set those manually.

What you might be able to do is using the "Update Service Reference" menu command instead of always creating a new service reference. This might preserve your settings (not sure - I never use it myself).

Related Topic