Creating an occasionally connected Smart Device Application RRS feed

  • Question


    I am trying to complete the above mentioned Microsoft Walkthrough  "Creating an occasionally connected Smart Device Application" ( http://msdn.microsoft.com/en-us/library/cc488004.aspx ) but it seems as if it is missing the code behind the 'on-click' event for the 'synchronize now' button.



    The end solution I am trying to design will be used as a portable checklist tool to inspect the quality of the physical installation of a conveyor system.  The Software engineer will create a basic checklist table in a SQL Server 2005 database located on a server in the main office.  The electrician on a remote site will use his/her laptop to get on the VPN back to the office, connect their PocketPC running Windows mobile 5.0 and SQL Server CE, and upload the basic checklist table from the remote office server.  The Electrician will then disconnect the PocketPC and go around the jobsite, checking what is indicated on the checklist, and entering if that item is OK or Not OK.  When the Electrician is complete, they will re-connect their PocketPC to their laptop and download the completed checklist back to the remote office database where the Software Engineer can run reports etc.



    • Can anyone help with completing the walkthrough?
    • AND/OR point me in the right direction to a good solution design philosophy?

    Thanks in advance

    • Moved by Tina_Tian Friday, April 22, 2011 7:55 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Monday, September 29, 2008 11:06 PM

All replies

  • On the bottom of the walkthrough page are community postings with the same problem.

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

    Good examples are available on:

    And steve lasker made some good webcasts.


    Wednesday, October 1, 2008 4:12 PM
  • That is not working because you need to define a remote and local provider. I can define the local provider as a new NorthwindCacheClientSyncProvider but there is no way to do the same for the server provider. Is there someone who has solved this problem?


    Thursday, October 2, 2008 10:24 AM
  • The RemoteProvider must be a ServerSyncProviderProxy().

    Watch this screencasts. They're very good.

    Thursday, October 2, 2008 10:53 AM

  • Hallo markus,
    I meet the same Problem. but I tried your code at the OnClick handler for my "Synchronize Now" Menu item.
    when the Programm try to execute

    but I receive a System.ArgumentNullException with the Error Message : " Value can not be null. Param name : ServerSyncProvider"

    In fact, the debugger show me that the feld : syncAgent.RemoteProvider is null.

    I think the Remote provider  or ServerProvider must be initialise on the SyncAgent using the web Reference to our WCF web service (in the case of our sample project, this web reference name is : NorthwindCacheWebRef. and the associated class name is : OCSDeviceApp.NorthwindCacheWebRef.NorthwindCacheSyncService).

    the problem is : I dont know practically how to initialise this ServerSyncProvider on the SyncAgent.


    Thursday, October 2, 2008 11:07 AM
  • I also thought that was the solution however i can't initialize the ServerSyncProvider either. I found the source code for the

    SyncProvider in the NorthwindCache.sync on the WCF library but I can't access it anywhere.

    Thursday, October 2, 2008 11:18 AM
  • You have to write your own serversyncproviderproxy class.

    I think the msdn walkthrough isn't a fully functional sample...

    Here is a full sample:

    Btw SyncGuru website provides many other nice samples.
    Thursday, October 2, 2008 1:49 PM

  • Hallo Markus

    the site  : http://www.syncguru.com/  is not found

    last Thursday, I went to this site without Problem but today the browser say : "page not Found"

    had the adress changed?

    Monday, October 6, 2008 11:12 AM
  • hmm,

    site seems to be down, but you can access it through google cache
    Monday, October 6, 2008 2:13 PM
  • I have been spent some time trying to find a WCF client based sample for devices that will work with the new Synchronization Services.  The walkthrough that started this thread leaves out the code behind the sync button.  By reading some of the other references mentioned here I can put together a desktop client app that will work.  The big difference is that on the desktop you can choose Add Service Reference which you cannot do on a device project.  I can use the tool  NetCFSvcUtil.exe to build the WCF proxy on the device but I cannot get it to work even though the rest of the project is identical to its desktop equivalent that does work.  I know that the proxy code produced by NetCFSvcUtil has limitations relative to the desktop Add Service Reference produced code.  Could someone from Microsoft or anyone else that would know comment on whether WCF on the device is capable of working with Synchronization Services.  I am started to believe that the reason the walkthrough left out the sync code is that the netcfSvcUtil produced proxy is just not compatible with Synchronization Services yet.


    I can get the asmx/web service code from the GBADeviceClient sample to work but I was hoping to use the latest WCF code.


    Sunday, October 26, 2008 3:12 PM
  • this code is enough for the code behind the 'on-click' :


    NorthwindCacheWebRef.NorthwindCacheSyncService serviceProxy = new OCSDeviceApp.NorthwindCacheWebRef.NorthwindCacheSyncService();


    NorthwindCacheSyncAgent syncAgent = new NorthwindCacheSyncAgent(serviceProxy);

    SyncStatistics syncStats = syncAgent.Synchronize();


    the demo is almost working for me, however I'm having problems with the upload (download works fine), Have someone the same problem? (I'm using sql 2005  <--- I think this is the problem....)

    Monday, October 27, 2008 3:24 AM
  • Here is a walkthrough that describes using the divce bits with the VS 2008 designer that might help:


    Occasionally Connected Applications (Devices)




    Walkthrough: Creating an Occasionally Connected Smart Device Application




    Sean Kelley

    Program Manager


    Monday, October 27, 2008 1:03 PM
  • Thanks a lot Jonathan.  What I really needed was to know that someone else got this working.  Once I saw your code I realized mine was ok and started looking for the problem somewhere else.  My problem was that I forgot to put the [XmlSerializerFormat()] attribute on the interface definition.  Curiously I also left this off when I built the desktop version and for whatever reason it works ok on the desktop but needs it for the device version to work.   I just needed the kick to look somewhere other than where I was looking.  For what its worth I also got the proxy produced by  NetCFSvcUtil.exe to work.  I am going to work on the upload next.  Are you trying to figure this out on your own or are you looking at "Walkthrough: Extending the Local Database Cache to Support Bidirectional Synchronization" http://msdn.microsoft.com/en-us/library/cc761546.aspx


    I have both versions of SQL setup.  I will report my progress.

    Tuesday, October 28, 2008 2:41 PM
  • Jonathan, even with your lines of code I cannot get the synchronization to work. When I press the synchronize button I get an TargenInvocation Exception. It says that it cannot connect to the network. I guess maybe something is wrong with my connection? How dit you manage to get the synchronization working?


    Wednesday, October 29, 2008 10:20 AM
  • Can you browse to wsdl inside your device?  If your working in the emulator perhaps you didn't cradle it.  It took me a while to figure out I needed to do that.  You would think starting the device from the debugger would cradle it but it doesn't.

    Wednesday, October 29, 2008 4:37 PM
  • I cannot browse to wsdl in my device but i have cradled it and the connection property of my windows mobile device center is set to allow DMA connections, i don't get what I'm doing wrong here, anybody has a clue?
    Thursday, October 30, 2008 8:45 AM
  • But when I change the computername into my IP address I CAN access the wsdl, I think it's very strange that i can't synchronize my application because it says it cannot connect to the network but when i try to access my webservice i can. I will try changing some things in my app.config where it uses the pc name, i'll change it into my ip address and try again.


    When i change the settings in my app.config from my pc-name to my ip-address i can access the WCF, but now i get an ArgumentException when i try to synchronize Sad
    Thursday, October 30, 2008 8:48 AM

  • Hi all,

    See my post in the Community Content of the Walkthrough and also on this thread:


    Hope this helps.
    Wednesday, November 5, 2008 10:42 AM
  • Hi robok,


    Thanks for your reply but it doesn't solve my argumentexception error. I still can't get the application to synchronize correctly. Is there anyone who had the same problem as i have and has solved it?




    I also followed all the options provided on this link:




    And this also has no effect on my application. At one moment I thought my ArgumentException could be solved by replacing the Collection<string> with string[] but this also doesn't work at all for me.

    Wednesday, November 5, 2008 2:21 PM