How to set (and why) the maximum message size quota

I am trying to use WPF and .NET 3.5 for the first time.

I have two questions:

1. In an existing .NET 2.0 WebService, I have these two lines right off the bat:

Private Share myService as ContactsWebService.Service1 = nothing
myService = New ContactsWebService.Service1

What is the .NET 3.5 version of these statements?

2. I tried

Dim MyService as ContactsWebService.Service1Soap = New ContactsWebService.Service1SoapClient

The compiler was happy, but when I called the first method:

myObject = MyService.mymethod

I get the "maximum size quota for incoming messages (65536) has been exceeded.....use the MaxReceivedMessageSize property on the the appropriate binding element"

Can someone straighten me out?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Meir RivkinFull stack Software EngineerCommented:
private static ContactsWebService.Service1 myService = null;
myService = New ContactsWebService.Service1();

2. open web.config and change the MaxReceivedMessageSize element
check this post for clarifications:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
On the service tag, specify the binding configuration name:

    <service behaviorConfiguration="OrderServiceBehavior" name="WCFService.OrderService">
      <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IOrderService"
        contract="WCFService.IOrderService" />
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

or try this:

System.ServiceModel.WSHttpBinding binding = new System.ServiceModel.WSHttpBinding(System.ServiceModel.SecurityMode.None);

binding.MaxReceivedMessageSize = 50000000;

System.ServiceModel.Description.MetadataExchangeClient mexClient = new System.ServiceModel.Description.MetadataExchangeClient(binding);

System.ServiceModel.Description.MetadataSet metadataSet = mexClient.GetMetadata(new System.ServiceModel.EndpointAddress("http://localhost:4000/mysite/aex"));

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.