Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7688445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:55:21+00:00 2026-05-31T19:55:21+00:00

I am very new to windows mobile development and MSFT Sync Framework as a

  • 0

I am very new to windows mobile development and MSFT Sync Framework as a heads up. I have a simple application that reads a barcode, retrieves entry from a database and lets the user enter a new reading. That all works just fine. However, when I attempt to synchronize I get the following exception:

System.ArgumentException was unhandled
  Message="ArgumentException"
  StackTrace:
       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 ElectricBarcodeApp.Form1.buttonSync_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 ElectricBarcodeApp.Program.Main()

Here is my code:

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlServerCe;
using System.IO;
using System.Reflection;

namespace ElectricBarcodeApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void buttonStart_Click(object sender, EventArgs e)
        {
            using (SqlCeConnection conn = new SqlCeConnection(
            ("Data Source=" + (Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase), "ElectricReading.sdf") + ";Max Database Size=2047"))))
            {

                // Connect to the local database 
                conn.Open();
                using (SqlCeCommand cmd = conn.CreateCommand())
                {
                    SqlCeParameter param = new SqlCeParameter();
                    param.ParameterName = "@Barcode";
                    param.DbType = DbType.String;
                    param.Value = textBarcode.Text.Trim();

                    // SELECT rows
                    cmd.CommandText = "SELECT Location, Reading FROM Main2 WHERE Barcode LIKE @Barcode";
                    cmd.Parameters.Add(param);

                    DataTable data = new DataTable();

                    using (SqlCeDataReader reader = cmd.ExecuteReader())
                    {

                            data.Load(reader);
                            this.dataGrid1.DataSource = data;

                    }

                }
            }


        }

        private void buttonEnter_Click(object sender, EventArgs e)
        {
            using (SqlCeConnection conn = new SqlCeConnection(
            ("Data Source=" + (Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase), "ElectricReading.sdf") + ";Max Database Size=2047"))))
            {

                // Connect to the local database 
                conn.Open();
                using (SqlCeCommand cmd = conn.CreateCommand())
                {

                    // INSERT NEW READING
                    cmd.CommandText = "UPDATE Main2 SET Reading = '" + textNewReading.Text.Trim() + "' WHERE Barcode LIKE '" + textBarcode.Text.Trim() + "'"; 

                    int m = cmd.ExecuteNonQuery();
                    cmd.ExecuteNonQuery();
                    if (m > 0)
                    {
                        MessageBox.Show("New Reading Successfully Entered:" + textNewReading.Text.Trim(), "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
                    }

                }
            }

        }

        private void buttonSync_Click(object sender, EventArgs e)
        {
            // The WCF Service
            ElectricReadingCacheWebRef.ElectricReadingCacheSyncService webSvcProxy = new
                ElectricBarcodeApp.ElectricReadingCacheWebRef.ElectricReadingCacheSyncService();

            // The Remote Server Provider Proxy
            Microsoft.Synchronization.Data.ServerSyncProviderProxy serverProvider = new
                Microsoft.Synchronization.Data.ServerSyncProviderProxy(webSvcProxy);

            // The Sync Agent
            ElectricReadingCacheSyncAgent syncAgent = new ElectricReadingCacheSyncAgent();
            syncAgent.RemoteProvider = serverProvider;
            //Main2 is the table to be synchronized
            syncAgent.Main2.SyncDirection = Microsoft.Synchronization.Data.SyncDirection.Bidirectional;

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

            // Show synchronization statistics
            MessageBox.Show("Changes Downloaded: " + stats.TotalChangesDownloaded.ToString() +
                "\r\n" + "Changes Uploaded: " + stats.TotalChangesUploaded.ToString());

        }



    }
}

The exception is thrown at this line:

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

I have been getting nowhere on finding a solution and any help is greatly appreciated!

EDIT: I thought it might be because I did not have:

using Microsoft.Synchronization;
using Microsoft.Synchronization.Data;

But adding that did not change the exception.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:55:22+00:00Added an answer on May 31, 2026 at 7:55 pm

    Double-click Your web reference to open it in Object Browser.

    Expand the node YourAppName.YourAppNameCacheWebRef.

    Right-click YourNameCacheSyncService and click Go To Definition.

    Reference.cs is opened in the Code Editor.

    Add the following code after the last using or imports statement:

    Imports Microsoft.Synchronization
    Imports Microsoft.Synchronization.Data
    

    Or, in C#:

    using Microsoft.Synchronization;
    using Microsoft.Synchronization.Data;
    

    Remove all classes and enumerations in the file except for YourNameCacheSyncService.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am basically a windows developer and very new to Sharepoint. I have Designed
i am very new to windows form UI development. now i am just doing
I am very new to XNA framework. I am writing a sample application in
I have a simple mobile app in Titanium that I'm using to debug the
I'm very new to programming, and I'd like to write a Windows Application. So
I have a Windows Mobile 6 Professional native project that runs ok on Win
very new to crystal reports.. Question is that - In our .net application we
I'm currently designing a windows mobile application using compact framework 3.5 and I need
I've got a .NET CF (C#) mobile application that I run on a windows
I'm very new to the mobile arena and have played with both iOS and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.