Domitius
Domitius

Reputation: 485

WCF with netTcpBinding binding and maxReceivedMessageSize error message

I'm trying to get my App.Config setup correctly to allow my NetTcp Service to return strings larger than 65536, because Im getting this error below

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.

So far this is what I've tried but it doesn't work, I was hoping someone could point out my mistake

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <system.web>
    <compilation debug="true" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="NetTcpSHWS.Service1" behaviorConfiguration="NetTcpSHWS.Service1Behavior">
        <host>
          <baseAddresses>
            <add baseAddress = "net.tcp://localhost:8732/Design_Time_Addresses/NetTcpSHWS/Service1/" />
          </baseAddresses>
        </host>
        <endpoint name="NetRcpEndPoint" address ="" binding="netTcpBinding" bindingConfiguration="netMyConfig" contract="NetTcpSHWS.IService1">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint name="NetTcpMetadataPoint" address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="NetTcpSHWS.Service1Behavior">
          <serviceMetadata httpGetEnabled="false"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
          <dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483646" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <netTcpBinding>
        <binding name="netMyConfig"
                 maxBufferSize="2147483647"
                 maxBufferPoolSize="2147483647"
                 maxReceivedMessageSize="2147483647"
                 transferMode="Buffered">
          <readerQuotas maxDepth="32"
                        maxStringContentLength="2147483647"
                        maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647" />
        </binding>
      </netTcpBinding>
    </bindings>
  </system.serviceModel>
</configuration>

This is just a test app

Upvotes: 0

Views: 4959

Answers (1)

ken2k
ken2k

Reputation: 49013

Add bindingConfiguration:

<endpoint name="NetRcpEndPoint" bindingConfiguration="myConfiguration" ... >

<netTcpBinding>
    <binding name="myConfiguration" ...
    </binding>
</netTcpBinding>

If you don't, your binding configuration won't be used (the default configuration will be used instead).

Upvotes: 1

Related Questions