Microsoft Sync Framework COM class error

Adam Right picture Adam Right · Jan 25, 2013 · Viewed 9.6k times · Source

I have been playing with "Microsoft Sync Framework 2.1" to sync two local sql server 2008 databases with an asp.net project.

my code:

SqlConnection clientConn = new SqlConnection(@"Server=XXXXXX;User ID=sa; Password=xxxx;Database=ZzzClient");

SqlConnection serverConn = new SqlConnection("Server=XXXXXX;User ID=sa; Password=xxxx;Database=ZzzServer");

SyncOrchestrator syncOrchestrator = new SyncOrchestrator();

syncOrchestrator.LocalProvider = new SqlSyncProvider("InventoryScope", clientConn);
syncOrchestrator.RemoteProvider = new SqlSyncProvider("InventoryScope", serverConn);

syncOrchestrator.Direction = SyncDirectionOrder.UploadAndDownload;

SyncOperationStatistics syncStats = syncOrchestrator.Synchronize();

but I get following error when the Synchronize() call is executed;

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)).

developing envoriement VS 2012, C# asp.net project, framework 4.5 OS:windows 7 Home Prem. (x64)

SyncSDK-v2.1-x64-ENU was installed.

Microsoft.Synchronization

Microsoft.Synchronization.Data

Microsoft.Synchronization.Data.SqlServer

references were added to project from "C:\Program Files\Microsoft Sync Framework\2.1\Runtime".

Both databases provisioned by SqlSyncScopeProvisioning.

I've tried Project Platform Target both x64 ans x86

Any ideas would be greatly appreciated....

Provisioned databases

I've changed the all references from "C:\Program Files (x86)\Microsoft SDKs\Microsoft Sync Framework" to "C:\Program Files\Microsoft Sync Framework\2.1\Runtime"

new references

And set the Platform Target to x64 Platform Target

"Use Local IIS Web Server" is selected Local IIS

UPDATE: I tried same process with a console application and it worked properly and synchronized all data.

I added following four references to console application;

"c:\Program Files\Microsoft Sync Framework\2.1\Runtime\x64\Microsoft.Synchronization.dll"

c:\Program Files\Microsoft Sync Framework\2.1\Runtime\ADO.NET\V3.1\x64\Microsoft.Synchronization.Data.dll"

"c:\Program Files\Microsoft Sync Framework\2.1\Runtime\ADO.NET\V3.1\x64\Microsoft.Synchronization.Data.Server.dll"

"c:\Program Files\Microsoft Sync Framework\2.1\Runtime\ADO.NET\V3.1\x64\Microsoft.Synchronization.Data.SqlServer.dll"

and set the application's debug properties as following console application's properties

Same references, same build properties(target to x64) and same code does not work for in Asp.Net project.

Could not load file or assembly 'WebApplication2' or one of its dependencies. An attempt was made to load a program with an incorrect format.

i guess, web application can't load correct assemblies and tries to load x86 versions

Answer

Adam Right picture Adam Right · Jan 28, 2013

I hate answering my own questions:

If you start an asp.net project which has x64 Sync Framework assemblies but you are NOT running Visual Studio under the administrator account, VS can not load Snyc Framework assemblies. At least, that's my problem..

If you are not administrator VS can not manage "Local IIS Web Server" properly.

Also if I'm not wrong, "IIS Express" can not load x64 Sync Framework assemblies even if your OS is x64.

Do not bother to use "IIS express" just use "Local IIS Web Server" with administrator rights on VS and set platform target x64 for your project.

enter image description here