WCF MaxStringContentLength is never updated!

Coders, this problem is driving me crazy !! The last 2 days I have been doing extensive research, and I have no idea what is going on.

Problem: As the name says, I have a WCF service that is consumed by a Silverlight application. The problem is that whenever I try to use one of the WCF operations, I get this error:

The maximum length of the string length (8192) was exceeded when reading XML data.

I know that I should change the MaxStringContentLength value in the web.config file to fit the size of my message, but it seems to me that updating the MaxStringContentLength value is not reflected in the system. I tried updating the service link, rebuilt the whole solution without any luck, and still got the same error. Any idea on what I should do?

Solution Information:

  • Asp.net project with WCF folder.

  • Silverlight project that consumes WCF.

Web.config

<system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_Service1" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> <readerQuotas maxDepth="32" maxStringContentLength="10000" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <security mode="None"> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="http://localhost:53931/WCF/Service1.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Service1" contract="ServiceReference.Service1" name="BasicHttpBinding_Service1" /> </client> <behaviors> <serviceBehaviors> <behavior name=""> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 

ServiceReferences.ClientConfig

 <configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_Service1" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" > <security mode="None" /> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="http://localhost:53931/WCF/Service1.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Service1" contract="ServiceReference.Service1" name="BasicHttpBinding_Service1" /> </client> </system.serviceModel> 

Thanks in advance.

+2
silverlight wcf
source share
1 answer

I do not see that the service is defined anywhere in the web.config file. You just have a customer definition. I am surprised that the service works like this. Copy and paste error, maybe?

Here is my web.config for a similar scenario (you miss the marked part):

 <system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> <behaviors> <serviceBehaviors> <behavior name="MyDefaultBehavior"> <serviceMetadata httpGetEnabled="true" /> </behavior> </serviceBehaviors> </behaviors> <bindings> <basicHttpBinding> <binding name="MyDefaultBinding" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000"> <readerQuotas maxDepth="500" maxArrayLength="20000000" maxStringContentLength="20000000"/> </binding> </basicHttpBinding> </bindings> <services> <!-- This appears missing from your web.config --> <service behaviorConfiguration="MyDefaultBehavior" name="MyProject.MyService"> <endpoint address="" binding="basicHttpBinding" contract="MyProject.IMyService" bindingConfiguration="MyDefaultBinding" /> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> </system.serviceModel> 
+2
source share

All Articles