none
Windows Store Apps - WCF - The maximum message size quota for incoming messages (65536) has been exceeded RRS feed

  • Question

  • Hi All,

    I have been creating a Windows Store app that requires WCF and have come across the following 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.

    My web.config file is as follows;

    <?xml version="1.0"?>
    <configuration>
    
      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation debug="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5"/>
      </system.web>
      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="BasicBinding" maxReceivedMessageSize="2000000" maxBufferSize="2000000" transferMode="Streamed">
              <readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000" maxBytesPerRead="2000000" maxNameTableCharCount="2000000" />
            </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" />
        </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>


    On research on the net I have found people talking about changing the binding to what I have above (and extract below);

    <binding name="BasicBinding" maxReceivedMessageSize="2000000" maxBufferSize="2000000" transferMode="Streamed">
              <readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000" maxBytesPerRead="2000000" maxNameTableCharCount="2000000" />
            </binding>


    I have been testing in the WCF Test Client and it will not work unless I change the config file from;

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="BasicHttpBinding_IService1" sendTimeout="00:05:00"/>
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://localhost:1325/Service1.svc" binding="basicHttpBinding"
                    bindingConfiguration="BasicHttpBinding_IService1" contract="IService1"
                    name="BasicHttpBinding_IService1" />
            </client>
        </system.serviceModel>
    </configuration>


    to;

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="BasicHttpBinding_IService1" sendTimeout="00:05:00"
                        maxBufferSize="2000000" maxReceivedMessageSize="2000000" />
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://localhost:1325/Service1.svc" binding="basicHttpBinding"
                    bindingConfiguration="BasicHttpBinding_IService1" contract="IService1"
                    name="BasicHttpBinding_IService1" />
            </client>
        </system.serviceModel>
    </configuration>

    And when I try and run this in my Win Store App it will not work.

    Hoping someone can help me,

    Cheers,

    Ben

    Saturday, May 17, 2014 12:46 PM

Answers

  • What you have done with readerQuotas on the client-side config will work on the client-side, but it won't work on the service-side config.That's if you have addressed the service-side.

    http://blogs.msdn.com/b/kaevans/archive/2008/01/24/wcf-and-custom-bindings.aspx

    Saturday, May 17, 2014 6:31 PM
  • Hi,

    I see that you are using the following config file in the service side:

    <basicHttpBinding>
            <binding name="BasicBinding" maxReceivedMessageSize="2000000" maxBufferSize="2000000" transferMode="Streamed">
              <readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000" maxBytesPerRead="2000000" maxNameTableCharCount="2000000" />
            </binding>
          </basicHttpBinding>


    Please try to apply this binding configuration to the endpoint as following:

      <endpoint address="" binding="basicHttpBinding"
                bindingConfiguration="BasicBinding" 
    contract="IService1" />


    Also in the windows store app, we can also using the channelfacotry to help us as following:

    var binding = new BasicHttpBinding();
            binding.MaxBufferPoolSize = 2147483647;
            binding.MaxBufferSize = 2147483647;
            binding.MaxReceivedMessageSize = 2147483647;
            binding.ReaderQuotas.MaxStringContentLength = 2147483647;
            binding.ReaderQuotas.MaxArrayLength = 2147483647;
            binding.ReaderQuotas.MaxDepth = 2147483647;
            binding.ReaderQuotas.MaxBytesPerRead = 2147483647;
    
    
            var address = new EndpointAddress("http://localhost:1325/Service1.svc");
    
            ChannelFactory<IService1> factory = new ChannelFactory<IService1>(binding, address);
    
            IService1 MyClientObject = factory.CreateChannel();
    ............

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Monday, May 19, 2014 3:37 AM
    Moderator

All replies

  • What you have done with readerQuotas on the client-side config will work on the client-side, but it won't work on the service-side config.That's if you have addressed the service-side.

    http://blogs.msdn.com/b/kaevans/archive/2008/01/24/wcf-and-custom-bindings.aspx

    Saturday, May 17, 2014 6:31 PM
  • How can I do this in a Windows Store App.

    Any guides.

    Cheers,

    Ben

    Sunday, May 18, 2014 5:18 AM
  • I don't know. You are going to have to hit Bing or Google for the information.
    Sunday, May 18, 2014 9:59 AM
  • Hi,

    I see that you are using the following config file in the service side:

    <basicHttpBinding>
            <binding name="BasicBinding" maxReceivedMessageSize="2000000" maxBufferSize="2000000" transferMode="Streamed">
              <readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000" maxBytesPerRead="2000000" maxNameTableCharCount="2000000" />
            </binding>
          </basicHttpBinding>


    Please try to apply this binding configuration to the endpoint as following:

      <endpoint address="" binding="basicHttpBinding"
                bindingConfiguration="BasicBinding" 
    contract="IService1" />


    Also in the windows store app, we can also using the channelfacotry to help us as following:

    var binding = new BasicHttpBinding();
            binding.MaxBufferPoolSize = 2147483647;
            binding.MaxBufferSize = 2147483647;
            binding.MaxReceivedMessageSize = 2147483647;
            binding.ReaderQuotas.MaxStringContentLength = 2147483647;
            binding.ReaderQuotas.MaxArrayLength = 2147483647;
            binding.ReaderQuotas.MaxDepth = 2147483647;
            binding.ReaderQuotas.MaxBytesPerRead = 2147483647;
    
    
            var address = new EndpointAddress("http://localhost:1325/Service1.svc");
    
            ChannelFactory<IService1> factory = new ChannelFactory<IService1>(binding, address);
    
            IService1 MyClientObject = factory.CreateChannel();
    ............

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Monday, May 19, 2014 3:37 AM
    Moderator