DCSIMG
Tables in a sync scope must be ordered - Manu Cohen-Yashar's Blog

Manu Cohen-Yashar's Blog

Tables in a sync scope must be ordered

Before doing synchronization using the Microsoft Sync Framework 2.0 it is required to provision a sync scope. In the scope you define which tables and columns are synchronized and specify any filters if required.

Detailed instruction can be found at the following resources:

Provisioning for Synchronization (SQL Server),

Walkthrough: Defining Filtered Scope and Provisioning Server Database,

Walkthrough: Defining Scope and Provisioning a Server Database

Yet one important detail is missing in all these references: The order of the tables in a scope.

 

When creating a scope for synchronizing multiple tables with parent child relationship the child must be declared first.

var scopeDesc = new DbSyncScopeDescription(scopeName);

scopeDesc.Tables.Add(
SqlSyncDescriptionBuilder.GetDescriptionForTable(chiledTable, serverConn));

scopeDesc.Tables.Add(
SqlSyncDescriptionBuilder.GetDescriptionForTable(parentTable, serverConn));

 

If you fail to do so the sync process will crash with OutOfMemory Exception.

It is not documented but multi table scopes assume that the tables are ordered according to the database constrains. If this assumption breaks loading the scope in the GetKnowledge method (In the beginning of the sync process) creates a huge memory block and the process fails.

 

I spent quite some time with this bug.

 

Manu

Comments

Robin Thomas said:

Code:

// create the sync orhcestrator

           SyncOrchestrator syncOrchestrator = new SyncOrchestrator();

           // set local provider of orchestrator to a sync provider associated with the

           // ProductsScope in the SyncExpressDB express client database

           syncOrchestrator.LocalProvider = new SqlSyncProvider("ProductsScope", clientConn);

           // set the remote provider of orchestrator to a server sync provider associated with

           // the ProductsScope in the SyncDB server database

           syncOrchestrator.RemoteProvider = new SqlSyncProvider("ProductsScope", serverConn);

           // set the direction of sync session to Upload and Download

           syncOrchestrator.Direction = SyncDirectionOrder.UploadAndDownload;

           // subscribe for errors that occur when applying changes to the client

           ((SqlSyncProvider)syncOrchestrator.LocalProvider).ApplyChangeFailed += new EventHandler<DbApplyChangeFailedEventArgs>(Program_ApplyChangeFailed);

           // execute the synchronization process

           SyncOperationStatistics syncStats = syncOrchestrator.Synchronize();

Error:

Retrieving the COM class factory for component with CLSID {EC413D66-6221-4EBB-AC55-4900FB321011} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

Can you help me solve this issue?

# December 3, 2010 12:42 PM

cristian said:

@Robin:

Your sync fx runtime is not correctly installed, install the sync framework runtime for your platform and try to run it again. (Look in internet for Sync Framework runtime)

# January 17, 2011 5:47 AM

ToratordDrale said:

InianLove|LOVE THIS SONG NOW!!!п»ї FIRST TIME HEARING IT!!! IM IN LOVE!!!!

 http://24pharmshop.com/?p=333

thplousaqq

# February 27, 2011 3:07 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: