I have a project with the following requirements:
- There must be a Desktop-based (preferably WinForms) client and a WP7-based client.
- Both will use the same data model
- The clients need to be able to sync with each other, and each is an OCA .
- The clients are completely independent (ie. can run at different times, and need not know the other even exists).
- The database is located on a remote server
As far as I can tell, the best way to do this is to use Sync Framework. Using the tools provided in the 4.0 CTP release, I have a web service that works great for the WP7 client, but cannot find an example of how to use this kind of service with a Windows Forms application.
Temporarily, syncing the windows forms application directly with the server (violating the remote server requirement), is acceptable, but I have not been able to make this work either (using the local database cache provided with Sync Framework 2.1). I can generate the files, but whenever I call "Synchronize" from the SyncAgent, I get a "MissingSessionVariable" exception.
I am using SQL Server 2008 and Visual Studio 2010 as my development tools, and C# as my development language.
I suggest you use the Sync Toolkit instead of the 4.0 CTP. The Sync Toolkit is what has become of the 4.0 CTP. You can download the bits here: http://code.msdn.microsoft.com/Sync-Framework-Toolkit-4dc10f0e
Now, the Local Database Cache wizard and the Sync Toolkit are using a different of set of sync providers and they track changes differently.
I suggest for your WP7-based client, you use the Sync Toolkit (which is actually built on top of Sync Framework 2.1).
For your WinForms app, use the full Sync Framework 2.1 using WCF and have both of your WP7 and WinForms app sync to the same scope on the server.
you can find a sample WinForm app here:
I'll try the code samples you provided; I assume that they will connect to the OData based WCF service correctly? Also, the last time I tried using the full Sync Framework (albeit without WCF) I always got a "MissingSessionVariable" exception when I called Synchronize(). Can you think of a reason that would be happening, or a way to fix it?
I previously downloaded the Sync Toolkit, when I built it it looked like it was just the CTP tools (SvcSyncUtil) with some client examples. Were there any other differences that I should be aware of? (Note: when i built and ran the tool project, it crashed...).
Thanks for the help.
the 4.0 CTP never made it a v4. MS instead release the CTP 4.0 bits as the Sync Toolkit. So, the Sync Toolkit is essentially the released bits of the supposedly v4.0.
The Sync Toolkit is primarily built for clients that can't have the full Sync Framework SDK/Runtime (SilverLight, WP7, iPhone, HTML5, etc...)
The Sync Toolkit service on the server side is still using Sync Framework 2.1. It's just exposing the endpoint as OData.
With regards to the error you got, how did you configure it? i'm guessing must be some wrong config somewhere.
Note that the Local Database Cache Wizard providers is totally different from what Sync Toolkit is using. So even if you get it running, you will end up with two totally different synchronization components (e.g. duplicate change tracking)
When I got the error, it was a default configuration. SQL Server 2008 with change tracking for the server (direct ADO.NET connection, no WCF or anything), SQL Server Compact for the local database cache. I set up a timer on my form to call Synchronize, and every time I would call it I got the exception (this was without any changes being made to any data).
I'm guessing there is something I need to add to the configuration, I just have no idea what.
Thanks again for the help.
have you tried regenerating the code? did you choose to sync incremental changes or just snapshot? you may also enable sync framework tracing to get a more detailed error.
yes, I tried regenerating the code and was always using incremental changes.
I looked at the code samples you suggested, and they definitely look like what I need. The only problem I am having is difficulty in locating the database specific fields that I need to modify for my actual schema. Is there a tutorial on how to use/modify this code for any use?
2012年3月8日 1:52版主which code sample are you referring to?
2012年3月8日 3:49版主the provisioning code is in ConfigureSqlSyncProvider inside the SynchronizationHelper.