Sync Services for ADO.NET on Windows Mobile - PROBLEMS!!! RRS feed

  • Question

  • The sample with this works fine, although I don't really understand how you get from a non-existent Sync Designer for Smart Devices to all that hand-edited code!


    The word document states:


    "Due to scoping decisions, we were not able to incorporate the Sync Designer for device projects into Visual Studio 2008.  However, the generated code from the Sync Designer can be used for device projects, and the designer does support targeting separate projects for its generated code. "


    Correct me, please if I am wrong. I would like to know just how this is supposed to work. I have successfully created a VS2008 solution with a Windows Forms desktop application, and even split it apart into a wcfServiceLibrary AND hosted the library within IIS (thanks to Steve Lasker's wonderful step-by-step videos). Sync downloads work like a charm!


    Now here are my expectations from the Word document that came with the ADO.NET (devices) stuff. There is NO WAY I am going to hand-edit all the Designer-generated code for a Smart Device project. So, what I tried was the following:

    1. Added a Smart Device project to the same solution.
    2. Added references for Microsoft.Synchronization.data.dll and Microsoft.Synchronization.Data.SqlServerCe.dll in \%programfiles%\Microsoft Synchronization Services\ADO.NET\v1.0\Devices.

    3. Double-clicked on the datacache.sync file in the aforementioned (amd successful) DESKTOP project. BUT, instead of asking it to generate the wcf server stuff, I asked it to generate the client-only SDF and sync files INTO THE SMART DEVICE project. It does this.

      I did the same wrapping for the proxy for the wcf-hosted web service that I did in the Desktop project:

      using ProxyWrapper = Microsoft.Synchronization.Data.ServerSyncProviderProxy;

      namespace AKTestSyncNTier {

      public partial class PremierDataCacheSyncAgent {

      partial void OnInitialized()


      this.RemoteProvider = new ProxyWrapper(new wcfPremierWebService.PremierDataCacheSyncContractClient());


      FIRST PROBLEM: you cannot add a "SERVICE REFERENCE" to a Smart Device project, only a web reference. OK, so I did that and changed the wrapper to wrap:

    4. No problem so far. It all compiles, although I had a problem since there are no SETTINGS files in a smart device project, I had to hand edit the client connection string to the local DB cache SDF file.
    5. Tried to run this and just do a SYNC with this code:

      PremierDataCacheSyncAgent syncAgent = new PremierDataCacheSyncAgent();

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

    6. First, VS 2008 tries to load DESKTOP verions of the DLLs, even though I know .NET compact framework 3.5 has been installed on the emulator device. Also getting 3 (related?) "REMAP" version errors on deploy.

    7. Then sync comes back with a cryptic error indicated there is some parameter deep in sync services that is not right and fails.




    • Moved by Max Wang_1983 Friday, April 22, 2011 6:52 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Tuesday, March 25, 2008 1:36 AM


All replies


    the steps seem correct to me. since the device project doesn't support adding WCF references, what you saw in step 3 is expected.


    I am concerned the finding in step 6 and 7. can you quickly try a standalone app just to load the sync service assemblies to see if it worked ?




    Thursday, March 27, 2008 11:33 PM
  • You can add Service Reference to your Smart Device project using NetCFSvcUtil.exe. This is part of NETCF power toy and can be downloaded from https://www.microsoft.com/downloads/details.aspx?FamilyId=C8174C14-A27D-4148-BF01-86C2E0953EAB&displaylang=en.


    The VS project system may have a reference to the desktop assemblies. Try deleting the obj\Debug\TempPe folder and rebuild the app. You should ensure that you've OCS device bits installed.


    PS: We're adding the designer support for Smart device projects in VS2008 SP1. The beta of SP1 should be out sometime before May. I'll post the details on my blog.




    Monday, March 31, 2008 8:13 AM
  • I've followed essentially the same steps as Aknittel: use desktop designer to generate sync agent code, copy to device project, use NetCFSvcUtil.exe to generate WCF server provider proxy.  I confirmed that the desktop client could successfully synchronize with the WCF service.
    When I run the device app., Microsoft.Synchronization.Data.ServerSyncProviderProxy.GetSchema(...) throws the following exception:

    "The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/Tongue TiedyncSession. The InnerException message was 'Error in line 1 position 862. 'EndElement' 'syncSession' from namespace 'http://tempuri.org/' is not expected. Expecting element '_clientId'.'.  Please see InnerException for more details."

    stack trace:
       at System.Web.Services.Protocols.SoapHttpClientProtocol.doInvoke(String methodName, Object[] parameters, WebClientAsyncResult asyncResult)
       at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
       at DeviceSyncClient.DataServer.LocalDataCacheSyncService.GetSchema(String[] tableNames, SyncSession syncSession)
       at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
       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.GetSchema(Collection`1 tableNames, SyncSession syncSession)
       at Microsoft.Synchronization.SyncAgent.InitClientSchema()
       at Microsoft.Synchronization.SyncAgent.Synchronize()
       at DeviceSyncClient.Form1.syncButton_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 DeviceSyncClient.Program.Main()

    I get the same exception when I replace the WCF proxy with a "Web Reference" proxy.

    Any ideas or workarounds?  Maybe this is already fixed for the SP1 build?

    Tuesday, April 15, 2008 10:04 PM
  • Hello Zac,


    i took me a while to get around this problem. But i found the solution.

    The Problem is Default Serialization Behaviour of WCF. By Default WCF on the serverside uses the DataContractSerializer. The clientside serializer uses the XmlSerializer. The DataContractSerializer serializes the internals of the SyncSession object. The XmlSerializer serializes the public interface of the SyncSession object.


    You can change the behaviour of the Serverside by Adding the [XmlSerializerFormat] Attribute to the serverside OperationContract.


    Search for [OperationContract()]. It has to look like:




    SyncContext ApplyChanges(SyncGroupMetadata groupMetadata, DataSet dataSet, SyncSession syncSession);



    SyncContext GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession);



    SyncSchema GetSchema(Collection<string> tableNames, SyncSession syncSession);



    SyncServerInfo GetServerInfo(SyncSession syncSession);



    Update the service references and everything works.



    Gerhard Allgaeuer

    Tuesday, May 20, 2008 12:12 PM
  • Hi Guys

    I have successfully created a VS2008 solution with a Windows Forms desktop application, following Steve's instructions.

    I added a smart device application to this solution, in order to get it working on a windows mobile.

    but It's not working. Because I can't add a service reference to it.

    Can u plz explain in more details the steps that I have to follow to make it working on a windows mobile.

    Thanks in advance.


    Tuesday, June 3, 2008 1:26 AM

    there seem to be mutiple issues being discussed here in this thread. could you try the sample from http://www.microsoft.com/downloads/details.aspx?FamilyID=75fef59f-1b5e-49bc-a21a-9ef4f34de6fc&displaylang=en to see if this worked under your envrioment ? pelease follow the instruction precisely when running the sample.





    Wednesday, June 4, 2008 10:11 PM
  • You are my own personal god.
    Friday, July 18, 2008 11:32 PM