Smart Device Development
Walkthrough: Creating an Occasionally Connected Smart Device Application

Updated: July 2008

This walkthrough provides step-by-step directions for configuring data synchronization in an occasionally connected smart device application. The sample application adds a customer to the local database cache and synchronizes the changes with a remote database. It also displays customer data on a Windows Form: this enables you to verify that synchronization is successful.

During this walkthrough, you will follow these steps:

  • Create a new Smart Device application.

  • Add a new Window Communication Foundation (WCF) Service Library which serves as a middle tier between the local database cache and the remote database.

    NoteNote:

    The middle tier service library is required because Synchronization Services for ADO.NET (Devices) does not support direct 2-tier synchronization.

  • Add a new Local Database Cache to the project.

  • Configure synchronization settings.

  • Configure and start the WCF service.

  • Add synchronization functionality to your device application.

  • Test the application.

Prerequisites

To complete this walkthrough you must:

Creating the Smart Device Application

NoteNote:

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

To create a new project on the desktop computer

  1. From the File menu, create a new project that uses either Visual Basic or Visual C#.

    NoteNote:

    The Configure Data Synchronization dialog box is supported in Visual Basic and C# projects. Therefore, make sure to select one of these languages.

  2. Name the solution Walkthrough and the project OCSDeviceApp.

  3. Under Project types, click Smart Device, and then Smart Device Project template.

  4. Click OK.

    The Add New Smart Device Project dialog box will appear. By default, the Windows Mobile 5.0 Pocket PC SDK target operating system, .NET Compact Framework version 3.5, and Device Application template are selected.

  5. Click OK.

    The OCSDeviceApp project is created and added to Solution Explorer.

Creating a WCF Service

Unlike desktop applications, the local SQL Server Compact database cache cannot synchronize directly with the remote SQL Server database for smart device projects. You must create a WCF service library that acts as a middle tier between the two databases. The device application uses services exposed by the WCF service for synchronization.

To add a WCF Service Library to the Solution

  1. From the File menu, point to Add, and then click New Project.

  2. Name the project MiddleTierServiceLibrary.

  3. Click WCF under Project types, followed by the WCF Service Library template.

  4. Click OK.

    The MiddleTierServiceLibrary project is created and added to Solution Explorer.

Adding a Local Database Cache

  • Unlike desktop applications, the Local Database Cache template is not available from the Add New Item dialog box of a smart device project. Instead, you must add a local database cache to the middle tier WCF or Web Service project.

To add a local database cache to a project

  1. Right-click the MiddleTierServiceLibrary project, point to Add, and then click New Item.

  2. Click the Local Database Cache template and type NorthwindCache.sync in the Name box.

  3. Click Add.

    A NorthwindCache.sync file is added to Solution Explorer and the Configure Data Synchronization dialog box appears. NorthwindCache.sync stores synchronization configuration information.

Configuring Synchronization Settings

To create data connections to the server and client databases

  1. Use the Configure Data Synchronization dialog box to create a connection to the Northwind database that you installed as a prerequisite to this walkthrough. This is the remote database external to your smart device application. You may either select an existing Server connection to the SQL Server Northwind database, or, if a connection does not exist, click New to create a new connection to the SQL Server Northwind database.

    NoteNote:

    You may enable SQL Server change tracking, but only after the connection to the remote database server is configured to connect to a SQL Server 2008 database. For more information, see How to: Configure Data Synchronization to Use SQL Server Change Tracking.

  2. Accept the default value of Northwind.sdf (new) for the Client connection. The Configure Data Synchronization dialog box creates a new SQL Server Compact 3.5 database and adds it to your project. For more information about the available data connection options, see How to: Create a Data Connection to the Northwind Database.

    After you select the server connection, the Configure Data Synchronization dialog box queries the remote database on the server for a list of available tables. This dialog box also enables the Add button, but only after the list of available tables is retrieved.

    NoteNote:

    Notice that the OK button is not enabled at the conclusion of this step. This is because no tables have been selected for synchronization. The next section explains how to add tables.

To add and configure tables for local caching

  1. Click Add to open the Configure Tables for Offline Use dialog box.

  2. Select the Customers table.

    NoteNote:

    You can modify the default synchronization behavior for each table that you select in the Configure Tables for Offline Use dialog box. For more information, see How to: Configure Data Synchronization in an Application.

  3. Accept the default column and table values. Click OK. The Configure Data Synchronization dialog box will create tracking columns and a deleted-items table if needed.

    The Customers table is added to the Cached Tables list.

To split synchronization components between the server and client projects

  1. In the Configure Data Synchronization dialog box, click Advanced.

  2. On the Client project location drop down menu, select OCSDeviceApp.

  3. Click OK.

    Components will be divided between the client project and the server project, after data synchronization is configured. Meanwhile, the Generate SQL scripts dialog box appears. By default, it generates scripts that maintain tracking columns and tables for deleted and updated items on the server database.

  4. Click OK.

    The generated SQL scripts are saved in the server project if needed. The Northwind.sdf client database is created in the client project and synchronized with the server database for the first time.

    NoteNote:

    SQL scripts are created only if modifications are required on the server. If the server already has a deleted items table and tracking columns or if you use SQL Server change tracking, no scripts are created.

  5. When the Data Source Configuration Wizard appears, select the Customers table.

  6. Click Finish.

    NorthwindDataSet.xsd is added to the client project and all dialog boxes close.

Now that synchronization is configured, the following items are added to the client project:

Item

Description

Northwind.sdf

  • A local database file that contains data cached from SQL Server.

NorthwindCache.Client.sync

  • An XML file that contains synchronization configuration information. Double-click this file to open the Configure Data Synchronization dialog box.

NorthwindCache.Client.Designer.cs (or .vb)

A code file that contains definitions for client sync provider and the sync agent. Also contains sync tables for the local database. For more information, see Architecture and Classes for Client and Server Synchronization.

NorthwindDataSet.xsd

  • The typed dataset generated by the Data Source Configuration wizard. This dataset contains a Customers table that is populated with data that is stored in the local database.

References\Microsoft.Synchronization.Data

References\Microsoft.Synchronization.Data.SqlServerCe

Required references to Microsoft Synchronization Services for ADO.NET.

The following items are added to the server project:

Item

Description

NorthwindCache.sync

An XML file that contains synchronization configuration information. Double-click this file to open the Configure Data Synchronization dialog box.

NorthwindCache.Designer.cs (or .vb)

Contains definitions for the Server Sync Provider and the Sync Adapter for the server database. For more information, see Architecture and Classes for Client and Server Synchronization.

NorthwindCache.SyncContract.cs (or .vb)

A code file that contains the WCF contract definition and its implementation.

SQLScripts folder

A folder of scripts. The scripts in this folder are used to track database changes on the server. Some of the scripts in this folder create the tracking columns, deleted items table. Other scripts in this folder create triggers that track changes on the server.

NoteNote:
SQL scripts are created only if modifications are required on the server. If the server already has a deleted items table and tracking columns or if you use SQL Server change tracking, no scripts are created.

SQLUndoScripts folder

The scripts in this folder delete the tracking columns, the items table, and any triggers that are used to track and respond to database changes on the server. Use these scripts to undo the changes made by the Configure Data Synchronization dialog box to the database.

NoteNote:
SQL scripts are created only if modifications are required on the server. If the server already has a deleted-items table and tracking columns or if you use SQL Server change tracking, no scripts are created.

References\Microsoft.Synchronization.Data

References\Microsoft.Synchronization.Data.Server

Required references to Microsoft Synchronization Services for ADO.NET.

Configuring and Starting the WCF Service

To configure the WCF service (NorthwindCacheSyncService) that is generated by the Configure Data Synchronization dialog box

  1. In Solution Explorer, double-click NorthwindCache.SyncContract.cs (or .vb) to open the file in the Code Editor.

  2. Add the XmlSerializerFormat() attribute just before the definition INorthwindSyncContract. The Code Editor should display:

  3. In Solution Explorer, double-click App.config.

  4. Make the following XML modifications to the App.config file. These changes configure the project to host the NorthwindCacheSyncService generated by the Configure Data Synchronization dialog box instead of the default service (Service1) that is generated by the WCF project template.

    1. Change <service name="MiddleTierServiceLibrary.Service1" behaviorConfiguration="MiddleTierServiceLibrary.Service1Behavior"> to <service name="MiddleTierServiceLibrary.NorthwindCacheSyncService" behaviorConfiguration="MiddleTierServiceLibrary.NorthwindCacheSyncServiceBehavior">

    2. Change <add baseAddress="http://localhost:8731/Design_Time_Addresses/MiddleTierServiceLibrary/Service1/" /> to <add baseAddress="http://<your computer IP address>:8731/NorthwindCacheSyncService/" />

    3. Change <endpoint address="" binding="wsHttpBinding" contract="MiddleTierServiceLibrary.IService1"> to <endpoint address="" binding="basicHttpBinding" contract="MiddleTierServiceLibrary.INorthwindCacheSyncContract">

      NoteNote:

      wsHttpBinding is not supported on devices.

    4. Change <dns value="localhost"/> to <dns value="<your computer IP address>"/>

    5. Change <behavior name="MiddleTierServiceLibrary.Service1Behavior"> to <behavior name="MiddleTierServiceLibrary.NorthwindCacheSyncServiceBehavior">

  5. Right-click MiddleTierServiceLibrary in Solution Explorer and click Set as StartUp Project.

  6. To start the WCF Service, click Start Without Debugging in the Debug menu.

    The Deploy OCSDeviceApp dialog box appears.

  7. Click Cancel and then Yes to continue.

    NoteNote:

    You are only starting the WCF service: the device emulator is not yet required.

    The WCF Service Host is started (icon appears in notification area) and hosts the service. The WCF Test Client appears and enables you to test the service.

    NoteNote:

    Make sure that the port is accessible and not blocked by a firewall.

Coding Synchronization Features in Your Smart Device Application

The previous steps configured your data synchronization options. In addition, you must add synchronization functionality to your smart device application.

Adding a Web reference from the project to the WCF service

  1. In Solution Explorer, right-click OCSDeviceApp, and then click Add Web Reference.

    The Add Web Reference dialog box appears.

  2. Type the address of the NorthwindCacheSyncService, such as http://IP Address:8731/NorthwindCacheSyncService/, in the URL box, and then click Go.

    NoteNote:

    Insure that there are no firewalls blocking port 8731 on the computer.

    Once the NorthwindCacheSyncService Web service is found, the Add Reference button is enabled.

    NoteNote:

    The service address may be found in the App.config file.

  3. Name the Web reference NorthwindCacheWebRef, and then click Add Reference.

    NorthwindCacheWebRef appears under Web References in Solution Explorer. Visual Studio generates the file Reference.cs: however, you will not be able to see this file in Solution Explorer.

  4. Perform the following steps to open and modify Reference.cs:

    1. Double-click NorthwindCacheWebRef to open it in Object Browser.

    2. Expand the node OCSDeviceApp.NorthwindCacheWebRef.

    3. Right-click NorthwindCacheSyncService and click Go To Definition.

      Reference.cs is opened in the Code Editor.

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

    5. Remove all classes and enumerations in the file except for NorthwindCacheSyncService.

      NoteNote:

      The removed types are already defined in the newly imported Microsoft.Synchronization and Microsoft.Synchronization.Data namespaces.

To create a data-bound form that is used to view data and initiate synchronization

  1. In Solution Explorer, double-click Form1 to open it in the Visual Studio designer.

  2. Drag the Customers node from the Data Sources window onto Form1.

  3. In Form1, click the left menu item and type Synchronize Now. Set its Name property to SynchronizeMenuItem.

    NoteNote:

    The user will ultimately click Synchronize Now to start the synchronization process.

  4. Double-click the Synchronize Now menu to create a menu-click event handler and open the form in the Code Editor.

  5. Add code that will start the synchronization process and refill the Customers table in the dataset. The code in the event handler should resemble the following:

    Visual Basic
    Cursor.Current = Cursors.WaitCursor
    
    ' The service reference
    Dim webSvcProxy = New NorthwindCacheWebRef.NorthwindCacheSyncService()
    
    ' The server provider
    Dim serverProvider = New Microsoft.Synchronization.Data.ServerSyncProviderProxy(webSvcProxy)
    
    ' The sync agent
    Dim syncAgent = New NorthwindCacheSyncAgent()
    syncAgent.RemoteProvider = serverProvider
    syncAgent.Customers.SyncDirection = Microsoft.Synchronization.Data.SyncDirection.Bidirectional
    
    ' Synchronize the databases
    Dim stats = syncAgent.Synchronize()
    
    ' Reload the DataSet/Datagrid from the local database
    CustomersTableAdapter.Fill(Me.NorthwindDataSet.Customers)
    
    ' Show synchronization statistics
    MessageBox.Show("Changes Downloaded: " + stats.TotalChangesDownloaded.ToString() + _
                vbCrLf + "Changes Uploaded: " + stats.TotalChangesUploaded.ToString())
    
    Cursor.Current = Cursors.Default
    
    C#
    Cursor.Current = Cursors.WaitCursor;
    
    // The WCF Service
    NorthwindCacheWebRef.NorthwindCacheSyncService webSvcProxy = new 
        OCSDeviceApp.NorthwindCacheWebRef.NorthwindCacheSyncService();
    
    // The Remote Server Provider Proxy
    Microsoft.Synchronization.Data.ServerSyncProviderProxy serverProvider = new 
        Microsoft.Synchronization.Data.ServerSyncProviderProxy(webSvcProxy);
    
    // The Sync Agent
    NorthwindCacheSyncAgent syncAgent = new NorthwindCacheSyncAgent();
    syncAgent.RemoteProvider = serverProvider;
    syncAgent.Customers.SyncDirection = Microsoft.Synchronization.Data.SyncDirection.Bidirectional;
    
    // Synchronize the databases
    Microsoft.Synchronization.Data.SyncStatistics stats = syncAgent.Synchronize();
    
    // Reload the DataSet/Datagrid from the local database
    customersTableAdapter.Fill(northwindDataSet.Customers);
    
    // Show synchronization statistics
    MessageBox.Show("Changes Downloaded: " + stats.TotalChangesDownloaded.ToString() +
        "\r\n" + "Changes Uploaded: " + stats.TotalChangesUploaded.ToString());
    
    Cursor.Current = Cursors.Default;
    

The DataGridView displays the Customers table from the local database cache (the Northwind.sdf database located in the project).

To add a customer to the local Northwind database

  1. In Solution Explorer, Double-click Form1 to open it in the designer.

  2. Click the menu item that is located on the right side of the form and type Insert Row. Set the menu item's Name property to InsertRowMenuItem.

  3. Double-click the Insert Row button to create a menu-click event handler and open the form in the Code Editor.

  4. Add code to connect to (and insert a row in) the local SQL Server Compact database.

    Visual Basic
    Dim conn = New System.Data.SqlServerCe.SqlCeConnection( _
        "Data Source=" + (System.IO.Path.Combine(System.IO.Path.GetDirectoryName( _
            System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase), "Northwind.sdf") + _
        ";Max Database Size=2047"))
    
    Try
        ' Connect to the local database
        conn.Open()
    
        ' Insert a row
        Dim cmd = conn.CreateCommand()
        cmd.CommandText = "INSERT INTO Customers ([CustomerID], [CompanyName]) Values('NEWRW', 'Northwind Traders')"
        cmd.ExecuteNonQuery()
    
    
    Catch ex As Exception
    Finally
        conn.Close()
    End Try
    
    ' Reload the DataSet/Datagrid from the local database
    CustomersTableAdapter.Fill(Me.NorthwindDataSet.Customers)
    
    C#
    System.Data.SqlServerCe.SqlCeConnection conn = new System.Data.SqlServerCe.SqlCeConnection(
        ("Data Source=" + (System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase), "Northwind.sdf") + ";Max Database Size=2047")));
    try
    {
        // Connect to the local database
        conn.Open();
        System.Data.SqlServerCe.SqlCeCommand cmd = conn.CreateCommand();
    
        // Insert a row
        cmd.CommandText = "INSERT INTO Customers ([CustomerID], [CompanyName]) Values('NEWRW', 'Northwind Traders')";
        cmd.ExecuteNonQuery();
    }
    
    finally
    {
        conn.Close();
    }
    
    // Reload the DataSet/Datagrid from the local database
    customersTableAdapter.Fill(northwindDataSet.Customers);
    

    InsertRowMenuItem inserts a new row in the Customers table in the local database.

    NoteNote:

    Later, when you test the application, you can verify that the new row appears in the remote database following synchronization.

Test the Application

Before you can test the application, you must connect and cradle the target device emulator so that it can connect to the NorthwindCacheSyncService service.

To test the application

  1. From the Tools menu, click Device Emulator Manager (DEM).

    The DEM window appears with a list of available emulators.

  2. Right-click USA Windows Mobile 5.0 Pocket PC R2 Emulator (the target device for OCSWalkthrough) and click Connect.

    The Pocket PC - WM 5.0 Device Emulator appears.

  3. In the DEM window, right-click the connected device and click Cradle.

    Windows Mobile Device Center (Windows Vista) or ActiveSync connects to the cradled device emulator. If Windows Mobile Device Center or ActiveSync offers to set up the device, click Connect without setting up your device (Windows Vista) or Cancel.

    NoteNote:

    The connection to WMDC or ActiveSync enables the emulator to access NorthwindCacheSyncService, which runs on the desktop computer. In order for the device emulator to connect, the connection settings in WMDC or ActiveSync must be configured to allow for DMA connections.

  4. Right-click OCSDeviceApp in Solution Explorer and click Set as StartUp Project.

  5. Press F5 to debug.

  6. Go back to the form in the Pocket PC - WM 5.0 Device Emulator and click Insert Row. The local database and remote database are no longer synchronized. However, a new row should be visible in the Datagrid.

  7. Click Synchronize Now.

    The local (desktop) database and remote (device) database should both have the new row.

  8. On the desktop computer, use Server Explorer/Database Explorer (or another database management tool) to connect to the remote server database and verify that the new record exists.

    1. In Server Explorer/Database Explorer, locate the Customers table on the remote database server (not the connection to Northwind.sdf).

    2. Right-click the Customers table and click Show Table Data.

    3. Verify that the new row exists.

    4. Right-click the new row and click Delete. The databases will again be unsynchronized.

  9. Go back to the form in Device Emulator and click Synchronize Now.

  10. Verify that the modifications to the remote database are synchronized to the local database and displayed in the grid.

  11. Close the form. (Stop debugging.)

See Also

Tasks

Concepts

Change History

Date

History

Reason

July 2008

Added topic.

SP1 feature change.

February 2009

Revised code sample.

Customer feedback.

Tags :


Community Content

allatthenook
ArgumentException was unhandled Error

Thank you very much for the code for the synchronization. I've added this to the project and on the following line of code...

Microsoft.Synchronization.Data.

SyncStatistics stats = syncAgent.Synchronize();

I'm getting the following error...

"ArgumentException was unhandled"

---

The stacktrace is as follows...

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.GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession)
at Microsoft.Synchronization.SyncAgent.DownloadChanges(SyncGroupMetadata groupMetadata)
at Microsoft.Synchronization.SyncAgent.Synchronize()
at OCSDeviceApp.Form1.SynchronizeMenuItem_Click(Object sender, EventArgs e)
at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
at System.Windows.Forms.Menu.ProcessMnuProc(Control ctlThis, WM wm, Int32 wParam, Int32 lParam)
at System.Windows.Forms.Form.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 OCSDeviceApp.Program.Main()


I've checked my mobile device can talk to my websevice by viewing it in internet explorer from the mobile device and it's fine.

Any help on this will be very much appreciated.

Tags :

mabarto
Solved: ArgumentException was unhandled Error

I had the same issue, you will get this error if you have forgotten to remove all the classes and enumerations in the file reference.cs
except the class NorthwindCacheSyncService.

See topic Adding a Web reference from the project to the WCF service point 4e.

Tags :

san007
ERROR:TargetInvocationException/ArgumentException

I am still facing the problem the same old prob.After removing the above mentioned classes and enumerations, i get TargetInvocationExeption Error. And if i dont then i get Argument Exception Error.

Also if possible can anyone provide me with a working VB example of the same....

Please provide me a sure shot solution to this problem......

Hoping to get a quick reply soon.....

Tags :

san007
Solved: TargetInvocationException/ArgumentException

The problem got solved...as mabarto told to remove all the classes and enums....The ArgumentException will get removed..Then to handle TargetInvocationException kindly change all your declarations in App.Config with respect to Database connectin path and the Service Binding Path ...change all the above mentioned to the physical address..i.e of database (eg: 192.168.0.5,1086>>port number) ,service etc...Do not put the Name of your Dev Mach...or Naming Sql Instance etc...

Tags :

jdelestre
publish WCF service ..

sorry for my langage i'm french :)
By following this step by step procedure (do not forget proxy!) Everything works as it should:
run the application, the WCF service is running well, thanks to the service host (small icon shown us) and sync works ... well
But it is when you are debugging via VS mode and an emulator!

When we publish OCSDeviceApp project on a PDA device, the executable that launches on-line (via ActiveSync) but not with VS (no debugging eh ..): when is what the WCF service runs there ? How can do i know whether it was launched? ==> Sync does not work: WebService error ... I suppose due to the service is not started!
How?
Is there published the WCF service (MiddleTierServiceLibrary project)? And how? Under IIS? I tried and it does not work better ...
I do not understand and I need help! For several months (yes!) Kills me that I look at all the forums on French and English: nothing !

Thank you for your help

Best regards

Tags :

Thomas Lee
Error-The given key was not present in the dictionary
Hi,
I am getting error when configure the Data Synchronization Settings: "The given key was not present in the dictionary"
To split synchronization components between the server and client projects
  1. In the Configure Data Synchronization dialog box, click Advanced.

  2. On the Client project location drop down menu, select OCSDeviceApp.

  3. Click OK."The given key was not present in the dictionary". -Get error after click ok.

I did installed everything mentioned in the Prerequisites section. 
Can somebody help here? Thanks a lot!

[tfl - 20 06 09] Hi - and thanks for your post. You should post questions like this to the MSDN Forums at http://forums.microsoft.com/msdn or the MSDN Newsgroups at http://www.microsoft.com/communities/newsgroups/en-us/. You are much more likely get a quicker response using the forums than through the Community Content. For specific help about:
Visual Studio : http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public.vstudio%2C&
SQL Server : http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public.sqlserver%2C&
.NET Framework : http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public.dotnet.framework
All Public : http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public%2C&


makis_g3
host this service inside IIS
I have question on how to host this service inside IIS. http://social.microsoft.com/Forums/en-US/uklaunch2007ado.net/thread/9bf0b2ce-7dba-46ab-bf31-b383caf4a7dc
Any guidness will be helpfull.
Thanks in advance.

Andrew-Murphy
Problems out the box - VS2008 CF3.5
This was just what I wanted except that it didn't work for me:
  1. The WCF service would not run and failed with an exception that started "The assembly with display name 'System.Xml.XmlSerializers' failed to load in the 'LoadFrom' binding context of the". Very strange. I fixed this by dropping all the auto-generated assembly references and adding what was needed back in.
  2. Every time I come to run the program and perform a synchronise, the Synchronize method on the syncAdapter throws an IOException with no detail. I cannot get past this error.

Any ideas? Running Windows 7 if that makes any difference.
Tags :

IntelliwaveDevloper
Error - System.MissingMemberException was unhandled
Hi all,

When I ran the project, it produced the error below.
at Microsoft.Synchronization.Data.ServerSyncProviderProxy.GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession)
at Microsoft.Synchronization.SyncAgent.DownloadChanges(SyncGroupMetadata groupMetadata)
at Microsoft.Synchronization.SyncAgent.Synchronize()
at SiteSense.Mobile.Reader.AssignTagForm.AssignTagForm_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form._SetVisibleNotify(Boolean fVis)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.Run(Form fm)
at SiteSense.Mobile.Reader.Program.Main()

I follow the guide here but no luck, maybe I'm missing a step or maybe the configuration for app.config is not correct. Here are the configuration of the app.config file:

<connectionStrings>
<add name="PositioningSyncService.Properties.Settings.ServerSiteSense_PositioningConnectionString"
connectionString="Data Source=www.mysite.com,9595;Initial Catalog=myDatabase;Persist Security Info=True;User ID=username;Password=password"
providerName="System.Data.SqlClient" />
</connectionStrings>
...
...
<services>
<service name="PositioningSyncService.PositioningSyncService" behaviorConfiguration="PositioningSyncService.PositioningSyncServiceBehavior">
<host>
<baseAddresses>
<add baseAddress ="http://192.168.4.113:8080/PositioningSyncService/"/> <--- my local ip address

</baseAddresses>

</host>
<endpoint address ="" binding="basicHttpBinding" contract="PositioningSyncService.IPositioningSyncContract"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="PositioningSyncService.PositioningSyncServiceBehavior">
<serviceMetadata httpGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="False" />

</behavior>
</serviceBehaviors>
</behaviors>

Should I change http://192.168.4.113:8080/PositioningSyncService/ to http://www.mysite.com:9595/PositioningSyncService/ ? If so, I need help for setting up WCF on that server. However I would like to test the sync service on my local before I set it up on my server.

The test used Windows Vista, Visual studio 2008 and Windows Mobile 6.0 Professional Emulator (can connect to the internet).

Please help me to solve this problem and thank you in advance.


IntelliwaveDevloper
Solved - System.MissingMemberException was unhandled
Hi, I solved this problem.

I didn't import Microsoft.Synchronization and Microsoft.Synchronization.Data namespaces in reference.cs.

However, under section "Adding a Web reference from the project to the WCF service", "Step 4d Add the following code after the last using or imports statement:" follow it is a blank statement, nothing. Until I read the note in step 4e. This is not a blaming, and of course I admit I didn't paying attention in detail, but hopefully, Microsoft can add these 2 name spaces Microsoft.Synchronization and Microsoft.Synchronization.Data after that step to clarify the walkthrough.

Other than that, this is a great walkthrough. Thanks.

Page view tracker