I have two sql server databases, One is server and other is client. I want to sync these databases. I have provisioned the Server and Client Db and Both of them provisioned successfully. But When I execute sync method It gives following error.
Retrieving the COM class factory for component with CLSID {046C184F-2188-4C99-A95A-9C0DCDC19050} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
My code to sync is-
SqlConnection clientConn = new SqlConnection(@"Data Source=.; Initial Catalog=SyncDbClient; Integrated Security=True");
SqlConnection serverConn = new SqlConnection("Data Source=.; Initial Catalog=SyncDb; Integrated Security=True");
// create the sync orhcestrator
SyncOrchestrator syncOrchestrator = new SyncOrchestrator();
// set local provider of orchestrator to a sync provider associated with the
// MySyncScope in the client database
syncOrchestrator.LocalProvider = new SqlSyncProvider("MySyncScope", clientConn);
// set the remote provider of orchestrator to a server sync provider associated with
// the MySyncScope in the server databasew
syncOrchestrator.RemoteProvider = new SqlSyncProvider("MySyncScope", 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();
// print statistics
Console.WriteLine("Start Time: " + syncStats.SyncStartTime);
Console.WriteLine("Total Changes Uploaded: " + syncStats.UploadChangesTotal);
Console.WriteLine("Total Changes Downloaded: " + syncStats.DownloadChangesTotal);
Console.WriteLine("Complete Time: " + syncStats.SyncEndTime);
Console.WriteLine(String.Empty);
Console.ReadLine();