none
WCF maxReceivedMessageSize auto config RRS feed

  • Question

  • I received the maxreceivedmessagesize error at client app, so I increased the size limit as below and made a temporary fix.

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <configSections>
        </configSections>
        <startup> 
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
        </startup>
        <system.serviceModel>
          <bindings>
            <basicHttpBinding>
              <binding name="BasicHttpBinding_IBaiscService" allowCookies="true"
                 maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647">
                <readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
              </binding>
            </basicHttpBinding>
          </bindings>
          <client>
            <endpoint address="http://localhost:4546/BaiscService.svc" binding="basicHttpBinding"
              bindingConfiguration="BasicHttpBinding_IBaiscService" contract="WCFBasicServ.IBaiscService"
              name="BasicHttpBinding_IBaiscService" />
          </client>
        </system.serviceModel>
    </configuration>

    My server configuration is :

    <?xml version="1.0"?>
    <configuration>
    
      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation debug="true" strict="false" explicit="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5" maxRequestLength="2147483647"/>
      </system.web>
      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="myBasicBinding" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647">
              <readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
            </binding>
          </basicHttpBinding>
        </bindings>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <protocolMapping>
          <add binding="basicHttpsBinding" scheme="https" bindingConfiguration="myBasicBinding"/>
        </protocolMapping>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
    
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
        <!--
            To browse web app root directory during debugging, set the value below to true.
            Set to false before deployment to avoid disclosing web app folder information.
          -->
        <directoryBrowse enabled="true"/>
      </system.webServer>
    
    </configuration>


    The problem is, when I delete and add the same reference at client app (VB and WPF app), the max limits which I specified are gone, is there a way client app could take the settings when I add the service reference?


    • Edited by surpavan Saturday, December 27, 2014 8:03 AM
    Saturday, December 27, 2014 8:02 AM

All replies