Feed Icon  


  • Bryant Likes
  • Send mail to the author(s) E-mail
  • twitter
  • View Bryant Likes's profile on LinkedIn
  • del.icio.us
Get Microsoft Silverlight
by clicking "Install Microsoft Silverlight" you accept the
Silverlight license agreement

Hosting By

Hot Topics


Open Source Projects



Remote File Sync using WCF and MSF

Posted in WCF | .NET | Sync Framework at Thursday, 03 January 2008 03:41 Pacific Standard Time


One of the things I've been looking into in my free time is the Microsoft Sync Framework (MSF) (currently in CTP mode). The MSF is:

[A] comprehensive synchronization platform enabling collaboration and offline for applications, services and devices with support for any data type, any data store, any transfer protocol, and network topology.


Included with the SDK is a sample called the Managed NTFS Sample which demonstrates how to create your own file sync provider for local files. This works pretty well for local files, but what I really want to do is a remote file sync over the Internet. The reason is that I built a family photo sharing website for my family and I use FolderShare to copy the files from each family member's computer up to my server. However, FolderShare only supports a limited number of shares and only supports 10,000 files per share. So with the idea of creating a custom FolderShare type of service I started to customize the sample. 

The remote file sync sample I created is still pretty rough around the edges since my goal was to just get it working. The sample is also only a one-way sync meaning file changes are only sent to the server and not back to the client (which is what I wanted). The service is a WCF service exposed via a website and right now the client is just a console application.

You can download a working sample of the code here.

I still have more to do on it and if there is enough interest I'll create a project on CodePlex for it. One of the first enhancements I'd like to make is to use ASP.Net membership to handle security and then create folders for each user instead of passing the root path in the sync service. There is lots of room for improvement.


Tuesday, 15 January 2008 07:47:35 (Pacific Standard Time, UTC-08:00)
A user testing your sample has posted a question regarding your sample here:


"I've been looking around at Brian Likes' demo app using FileSync. I fired up the service on on computer, and then the client on the other. The upload sync worked...once. On every subsequent test, I've gotten an InvalidOperationException on the syncAgent.Synchronize call, with the message that "LastWriteTimeUtc not yet set." I couldn't find a property called LastWriteTimeUtc in any object in the list of local variables, and both an MSDN and a Google search didn't yield any sort of usable results either. Does anyone have any idea what the cause could be? Thanks."
Tuesday, 22 January 2008 09:06:04 (Pacific Standard Time, UTC-08:00)
I just wanted to thank you for posting this code. I have been trying to get my head around how to accomplish this today and this should really help out. Please continue to post updates, I will appreciate it very much.
Jeffrey Peters
Tuesday, 19 February 2008 00:18:16 (Pacific Standard Time, UTC-08:00)
Thx for ur code. I m new to MSF but i wish to try ur code and learn something from it. So, can u briefly let me know the steps on how to host ur code in iis and how to use ur client console application in remote computer? i doesn't which classes are needed to host and which classes are needed in client side. Ur help are appreciated. thx again.
Monday, 10 March 2008 03:07:56 (Pacific Standard Time, UTC-08:00)
Change batch cannot be serialized any more with CTP2 the following error occurs any input would be greatly appreciated
{"The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://ektron.com/filesyncservice:sourceChanges. The InnerException message was 'There was an error deserializing the object of type Microsoft.Synchronization.ChangeBatch. Xml representation of the object is invalid.'. Please see InnerException for more details."}
Chandrashekar Kollipara
Friday, 02 May 2008 01:22:58 (Pacific Daylight Time, UTC-07:00)
I downloaded the sample and tried to complile with VS 2008 and got the following error. I did install the latest version of Microsoft Sync Framework:

Error 1 The type or namespace name 'ChangeBatchBuilder' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\RAryan\Desktop\RemoteSync\RemoteSync.Common\SyncDetails.cs 68 13 RemoteSync.Common
Tuesday, 29 July 2008 07:55:56 (Pacific Daylight Time, UTC-07:00)
Hey Thanks! This was just the example I was looking for! Great work!
Wednesday, 01 October 2008 16:32:20 (Pacific Daylight Time, UTC-07:00)
Hi, this is just the sample I needed.
Could you please update the sample to support the RTM version of MSF.
Tuesday, 09 December 2008 05:49:00 (Pacific Standard Time, UTC-08:00)
Is there a way to synchronize two folders over the web? Can we use MS Sync Services to synchronize the Source and Destination folder which are web URL addresses (such as http:\\www.abc.com\srcFldr & http:\\www.abc.com\destFldr) instead of C:\sync1 & C:\sync2. If yes, do you have an example.

I was able to comile your code, but when I run it I am getting object null ref error when calling SyncOrchestrator's Synchronize function? any idea why?
Monday, 02 March 2009 06:53:55 (Pacific Standard Time, UTC-08:00)
Could you provide working Sample code for MS Sync File System service CTP2 with Using WCF
Tuesday, 03 March 2009 00:19:34 (Pacific Standard Time, UTC-08:00)
Hi Bryant,Thnx for ur code.
I am getting error "Operation is not valid due to the current state of the object." in ProcessChangeBatch() method at
localVersions = service.GetChanges(folderPath, sourceChanges);
any idea why?
I tried to modify code for latest version of sync framework.
Wednesday, 01 April 2009 07:04:51 (Pacific Standard Time, UTC-08:00)
Can you please provide a working sample with the latest sync framework.
Sunday, 23 August 2009 18:51:53 (Pacific Daylight Time, UTC-07:00)
I would need this example with the latest synchronization framework version
Comments are closed.