• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5232
  • Last Modified:

setting up MaxReceivedMessageSize in App.Config for WCF

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

1 Solution
CMXUserAuthor Commented:
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now