Welcome to MSDN Blogs Sign in | Join | Help

MADHU@MICROSOFT BLOG

All About Distributed apps

Syndication

News

Madhu Ponduru works at Microsoft. Everything here, though, is his personal opinion and is not read or approved by Microsoft before it is posted. No warranties or other guarantees will be offered as to the quality of the opinions or anything else offered here.
How to change reader quota values programmatically

Example:

 

XmlDictionaryReaderQuotas quotas = new XmlDictionaryReaderQuotas();

quotas.MaxArrayLength = int.MaxValue;

quotas.MaxBytesPerRead = int.MaxValue;

quotas.MaxDepth = int.MaxValue;

quotas.MaxNameTableCharCount = int.MaxValue;

quotas.MaxStringContentLength = int.MaxValue;

NetTcpBinding tcpBinding = new NetTcpBinding();

tcpBinding.ReaderQuotas = quotas;

 

 

Published Wednesday, September 20, 2006 1:35 PM by madhu_ponduru@hotmail.com

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: How to change reader quota values programmatically @ Thursday, October 09, 2008 12:38 PM

That's it?  You don't have to set this new NetTcpBinding somewhere? It just magically works?

uncle

# re: How to change reader quota values programmatically @ Thursday, October 16, 2008 7:51 PM

If you have self host app, This is how complete code looks like

// Host the service within this EXE console application.

       public static void Main()

       {

           //Define reader quotas

               XmlDictionaryReaderQuotas quotas = new XmlDictionaryReaderQuotas();

               quotas.MaxArrayLength = int.MaxValue;

               quotas.MaxBytesPerRead = int.MaxValue;

               quotas.MaxDepth = int.MaxValue;

               quotas.MaxNameTableCharCount = int.MaxValue;

               quotas.MaxStringContentLength = int.MaxValue;

           //Assign reader quotas to binding

               NetTcpBinding tcpBinding = new NetTcpBinding();

               tcpBinding.ReaderQuotas = quotas;

           //use above binding

               ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService),new Uri("http://localhost:8081/testsvc"));

               serviceHost.AddServiceEndpoint("Microsoft.ServiceModel.Samples.ICalculator", tcpBinding, new Uri("net.tcp://localhost:9000/testsvc1/ep1"));

               serviceHost.Open();

               Console.WriteLine("service is ready");

               Console.ReadKey();

       }

madhu_ponduru@hotmail.com

# re: How to change reader quota values programmatically @ Monday, March 30, 2009 12:41 AM

Hi,

I'm developing WCF application.

During  which I'm getting error "The remote server returned an unexpected response: (400) Bad Request." even after  increasing the request quota size in the configuration file at the client side to "2147483647"

Can you please help me out to resolve the issue.

Regards,

Sreejith

Sreejith

# re: How to change reader quota values programmatically @ Friday, July 31, 2009 12:13 PM

We may get 400 Bad request for different reasons, it may or may not be related to reader quotas, Please enable WCF tracing, Tracing will show why server throwing 400 error

http://blogs.msdn.com/madhuponduru/archive/2006/05/18/601458.aspx

madhu_ponduru@hotmail.com

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement  
Page view tracker