Click here to Skip to main content
15,891,881 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

In my WCF application the maximum number of characters allowed id becoming 8012.How can i increase it?

I am getting the following error

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:_objProducts. The InnerException message was 'There was an error deserializing the object of type SysInterfaceML.Management.ProductsML. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 326, position 77.'. Please see InnerException for more details.
Posted
Updated 11-Apr-11 0:07am
v3

Start by changing
MSIL
I would start here:
maxReceivedMessageSize="65536"
in your WCF configuration.
 
Share this answer
 
Comments
deepak thomas 11-Apr-11 7:12am    
I have changed the values.But when i delete and add the service reference again it is getting back to default values.
Abhinav S 11-Apr-11 13:09pm    
OK you need to figure a way around that. But does changing the value help?
#realJSOP 11-Apr-11 13:34pm    
That's always going to happen when you add a service reference.
It cant be set in the configuration file.you have to set in via programmatically

create an XmlDictionaryReaderQuotas object and set maxium value to all.and apply this object to your binding and call the proxy

sample code is:-
BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
           EndpointAddress endPoint = new EndpointAddress(URI of your wcf);
           basicHttpBinding.MaxBufferSize = int.Parse("2147483647");
           basicHttpBinding.MaxReceivedMessageSize = int.Parse("2147483647");
           XmlDictionaryReaderQuotas readerQuotas = new XmlDictionaryReaderQuotas();
           readerQuotas.MaxStringContentLength = int.Parse("2147483647");
           readerQuotas.MaxArrayLength = int.Parse("2147483647");
           basicHttpBinding.ReaderQuotas = readerQuotas;
           using (your proxy client= new  your proxy Client(basicHttpBinding, endPoint))
           {
               client.Open();
               success = client.your wcf function();
           }
 
Share this answer
 
v2
Comments
deepak thomas 11-Apr-11 7:16am    
where to write?
Nithin kd 11-Apr-11 7:25am    
you have to write this code in the client project of wcf
deepak thomas 11-Apr-11 7:36am    
the same error is getting
deepak thomas 11-Apr-11 7:37am    
i have written like this

SysInterfaceWCFService.SysInterfaceWCFServiceClient _WCFClient;

BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
EndpointAddress endPoint = new EndpointAddress("http://localhost:1077/SysInterfaceWCFService.svc");
basicHttpBinding.MaxBufferSize = int.Parse("2147483647");
basicHttpBinding.MaxReceivedMessageSize = int.Parse("2147483647");
XmlDictionaryReaderQuotas readerQuotas = new XmlDictionaryReaderQuotas();
readerQuotas.MaxStringContentLength = int.Parse("2147483647");
readerQuotas.MaxArrayLength = int.Parse("2147483647");
basicHttpBinding.ReaderQuotas = readerQuotas;
using (_WCFClient = new SysInterfaceWCFService.SysInterfaceWCFServiceClient(basicHttpBinding, endPoint))
{
_WCFClient.Open();
updatedProductID = _WCFClient.UpdateProducts(_objProducts, _objLoginCredentials);
if (updatedProductID > 0)
{
return updatedProductID;
}
else
{
return 0;
}

}
deepak thomas 11-Apr-11 7:38am    
error

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:_objProducts. The InnerException message was 'There was an error deserializing the object of type SysInterfaceML.Management.ProductsML. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 89, position 61.'. Please see InnerException for more details.
By modifying the “maxReceivedMessageSize” in the Web.config file to accept large messages, you can solve this issue.

XML
<system.servicemodel>
  <bindings>
    <basichttpbinding>
      <binding maxreceivedmessagesize="10485760">
        <readerquotas ...="" />
      </binding>
    </basichttpbinding>
  </bindings>  
</system.servicemodel>


http://tharakaweb.com/2012/12/11/413-request-entity-too-large/[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900