5

Here is my Web.config on Windows Azure Services Project

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <configSections>
  </configSections>
  <!--  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.
  <system.diagnostics>     
    <sharedListeners>
      <add name="AzureLocalStorage" type="NutriLeaf.Services.AzureLocalStorageTraceListener, NutriLeaf.Services"/>
    </sharedListeners>
    <sources>
      <source name="System.ServiceModel" switchValue="Verbose, ActivityTracing">
        <listeners>
          <add name="AzureLocalStorage"/>
        </listeners>
      </source>
      <source name="System.ServiceModel.MessageLogging" switchValue="Verbose">
        <listeners>
          <add name="AzureLocalStorage"/>
        </listeners>
      </source>
    </sources> 
   </system.diagnostics> -->

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

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>




  <system.serviceModel>


    <bindings>
      <basicHttpBinding>
        <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=""/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>

    <behaviors>
      <serviceBehaviors>
        <behavior>
          <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" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

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

and Here's the Exception I get on my Windows Phone 7 client

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

I've even tried setting the TransferMode="Streamed" but this didnot help, I get the same exception. Could you please help me out. Am I missing the parts of the Web.config file?

Please help!

Nawaz Dhandala
  • 2,046
  • 2
  • 17
  • 23
  • What are the values for the MaxReceivedMessageSize and MaxBufferSize on the client? It might be the settings don't match on your phone (the client), rather than the service. – Tim Mar 17 '12 at 16:28
  • Can you post the full `Exception.ToString()` value? – Pedro Lamas Mar 17 '12 at 20:24
  • I had same problem and totally removed WCF service reference from client and added it again. Problem fixed. Hope this helps. – Teoman shipahi Mar 08 '13 at 02:59

2 Answers2

6

The problem is probably being generated on the client. Check your ServiceReferences.ClientConfig file on your WP7 app and check the bindings.

They should look like this:

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

You need to make sure that the maxBufferSize and maxReceivedMessageSize are the same as those values in your server config.

KyleMit
  • 30,350
  • 66
  • 462
  • 664
Faster Solutions
  • 7,005
  • 3
  • 29
  • 45
3

I encountered the same issue. I don't know whether this is a bug in the WP7 Silverlight runtime, however it worked properly if the binding was rather defined in code instead of the ServiceReferences.ClientConfig. Something like this:

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.

Mark Vincze
  • 7,737
  • 8
  • 42
  • 81