How to set the MaxReceivedMessageSize programmatically when using a WCF Client?
wcf
Solution
Have you tried re-ordering the calls so that you set the MaxReceivedMessageSize before instantiating the client? eg,
var binding = new wsHttpBinding();
binding.MaxReceivedMessageSize = Int32.MaxValue;
var wcfClient = new WCFServiceTestClient(binding, strServiceURL);
This may or may not help your 400 error, though.
Problem
I want to set the MaxReceivedMessageSize property to some higher limit (Due to (400) Bad Request error) in my client programmatically. This is the code I am using... ``` WCFServiceTestClient wcfClient = new WCFServiceTestClient(new wsHttpBinding(), strServiceURL); ``` My service url is dynamic and hence cannot use the web.config. ``` //The following code doesn't seem to take effect ((WSHttpBinding)wcfClient.ChannelFactory.Endpoint.Binding) .MaxReceivedMessageSize = 2147483647; ``` What am I doing wrong?