I am getting for TransferMode.Buffered, MaxReceivedMessageSize and MaxBufferSize must be the same value

Here is my Web.config in a Windows Azure Services project

<?xml version="1.0" encoding="UTF-8"?>
  <!--  To collect diagnostic traces, uncomment the section below or merge with existing system.diagnostics section.
        To persist the traces to storage, update the DiagnosticsConnectionString setting with your storage credentials.
        To avoid performance degradation, remember to disable tracing on production deployments.
      <add name="AzureLocalStorage" type="NutriLeaf.Services.AzureLocalStorageTraceListener, NutriLeaf.Services"/>
      <source name="System.ServiceModel" switchValue="Verbose, ActivityTracing">
          <add name="AzureLocalStorage"/>
      <source name="System.ServiceModel.MessageLogging" switchValue="Verbose">
          <add name="AzureLocalStorage"/>
   </system.diagnostics> -->

        <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
          <filter type="" />

    <compilation debug="true" targetFramework="4.0" />


        <binding closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          allowCookies="true" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>

          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="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="true" />
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

    <modules runAllManagedModulesForAllRequests="true" />
        <remove name="LocalSqlServer" />
        <add connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" name="LocalSqlServer" providerName="System.Data.SqlClient" />


and here is the Exception I am getting on my Windows Phone 7 client

For TransferMode.Buffered, MaxReceivedMessageSize and MaxBufferSize must be the same. Parameter name: bindingElement

I even tried to set TransferMode = "Streamed" but it didn't help, I get the same exception. Could you help me. Am I missing parts of the Web.config file?

Please, help!


source to share

2 answers

I faced the same problem. I don't know if this is a bug in the WP7 Silverlight runtime, however it worked correctly if the binding was defined in code rather than ServiceReferences.ClientConfig. Something like that:

var client = new MyServiceClient(
    new BasicHttpBinding( BasicHttpSecurityMode.None )
        MaxReceivedMessageSize = 2147483647,
        MaxBufferSize = 2147483647
    new EndpointAddress( yourAddress ) );


I couldn't figure out the reason for this yet.



Probably the problem is on the client. Check the ServiceReferences.ClientConfig file in your WP7 app and check the bindings. they should look like this:

        <binding name="{YOUR SERVICE NAME HERE" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> 
    <security mode="None" /> 


You need to make sure maxBufferSize and maxReceivedMessageSize match these values ​​in your server configuration.



All Articles