Partager via


How to change MetadataExchangeClient reader quota values

            CustomBinding mexBinding = new CustomBinding(MetadataExchangeBindings.CreateMexHttpBinding());
           
            for (int i = 0; i < mexBinding.Elements.Count; i++)
            {

                HttpTransportBindingElement transport = mexBinding.Elements[i] as HttpTransportBindingElement;
                if (transport != null)
                {
                    transport.MaxReceivedMessageSize = int.MaxValue;
                   
                }
                TextMessageEncodingBindingElement textMEBE =

                    mexBinding.Elements[i] as TextMessageEncodingBindingElement;
              

                if (textMEBE != null)
                {

                    textMEBE.ReaderQuotas.MaxArrayLength = textMEBE.ReaderQuotas.MaxBytesPerRead =

                        textMEBE.ReaderQuotas.MaxDepth = textMEBE.ReaderQuotas.MaxNameTableCharCount =

                        textMEBE.ReaderQuotas.MaxStringContentLength = int.MaxValue;

                }

            }

            MetadataExchangeClient mexClient = new MetadataExchangeClient(mexBinding);