setting up MaxReceivedMessageSize in App.Config for WCF

Posted on 2009-04-16
Last Modified: 2012-05-06
I am using a sample project which is synching data through WCF Service and using Bidirectional Sync mentioned at the following url for a sample table of my own

I ran this for various test cases. I created 1000 rows on server and used Sync to transfer data to the client
I made changed in some of those data on the client and used the Sync to reflect those changes on the server

Then I added 200 new rows on client and used sync to send these rows back to the server

However when I added 300 new rows on client and used sync to send these rows back to the server i get the "TargetInvocationException" when i execute

Microsoft.Synchronization.Data.SyncStatistics stats = syncAgent.Synchronize();

following is the stack trace

   at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess, StackCrawlMark& stackMark)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Microsoft.Synchronization.Data.ServerSyncProviderProxy.ApplyChanges(SyncGroupMetadata groupMetadata, DataSet dataSet, SyncSession syncSession)
   at Microsoft.Synchronization.SyncAgent.UploadChanges(SyncGroupMetadata groupMetadata)
   at Microsoft.Synchronization.SyncAgent.Synchronize()
   at TestUI.Form1.button2_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.ButtonBase.WnProc(WM wm, Int32 wParam, Int32 lParam)
   at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
   at Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)
   at System.Windows.Forms.Application.Run(Form fm)
   at TestUI.Program.Main()

I found MaxReceivedMessageSize property to set up the upload limit
Now I have to figure out how to plug it in the following app.config. If any one has experience with this plz direct me
Thank you all for your time
<?xml version="1.0" encoding="utf-8" ?>





    <add name="WCFProxy.Properties.Settings.ServerNewQuestConnectionString"

      connectionString="Data Source=\SQLEXPRESS;Initial Catalog=NewQuest;User ID=appuser;Password=appuser"

      providerName="System.Data.SqlClient" />



    <compilation debug="true" />


  <!-- When deploying the service library project, the content of the config file must be added to the host's 

  app.config file. System.Configuration does not support config files for libraries. -->



      <!--service name="WCFProxy.Service1" behaviorConfiguration="WCFProxy.Service1Behavior" -->

      <service name="WCFProxy.ExceptionDetailsSyncService" behaviorConfiguration="WCFProxy.ExceptionDetailsSyncServiceBehavior">



            <!-- add baseAddress="http://localhost:8731/Design_Time_Addresses/WCFProxy/Service1/"   / -->

            <add baseAddress=""   />



        <!-- Service Endpoints -->

        <!-- Unless fully qualified, address is relative to base address supplied above -->

        <!--endpoint address=""  binding="wsHttpBinding" contract="WCFProxy.IService1" -->

        <endpoint address=""  binding="basicHttpBinding" contract="WCFProxy.IExceptionDetailsSyncContract">


              Upon deployment, the following identity element should be removed or replaced to reflect the 

              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 




            <!-- dns value="localhost"/ -->

            <dns value=""/>



        <!-- Metadata Endpoints -->

        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 

        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->

        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>





        <!--behavior name="WCFProxy.Service1Behavior" -->

        <behavior name="WCFProxy.ExceptionDetailsSyncServiceBehavior">

          <!-- To avoid disclosing metadata information, 

          set the value below to false and remove the metadata endpoint above before deployment -->

          <serviceMetadata httpGetEnabled="True"/>

          <!-- To receive exception details in faults for debugging purposes, 

          set the value below to true.  Set to false before deployment 

          to avoid disclosing exception information -->

          <serviceDebug includeExceptionDetailInFaults="True" />






Open in new window

Question by:CMXUser
    1 Comment

    Accepted Solution

    i managed to add the following Binding settings to make it work
    Thanks All
            <binding name="basicHttpBindingSettings" closeTimeout="00:10:00" openTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" messageEncoding="Text">
              <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />

    Open in new window


    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    In previous Articles, we have discussed how we can upload a file using .asmx web service and isolated storage space. Here, in continuation to the topic, I am going to discuss how we can use WCF for the same purpose. Steps: 1.Create the silverli…
    Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now