Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft Sync Framework COM class error

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

like image 427
Adam Right Avatar asked Jan 25 '13 10:01

Adam Right


People also ask

What is Microsoft Sync Framework Do I need it?

Sync Framework is a comprehensive synchronization platform that enables collaboration and offline access for applications, services, and devices. Sync Framework features technologies and tools that enable roaming, data sharing, and taking data offline.

What is Microsoft Sync Framework used for?

Microsoft Sync Framework is a comprehensive synchronization platform that enables collaboration and offline scenarios for applications, services, and devices. Using Microsoft Sync Framework, developers can build applications that synchronize data from any source using any protocol over any network.


3 Answers

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

like image 88
Adam Right Avatar answered Oct 20 '22 08:10

Adam Right


I use the 64bit Sync Framework DLLs and had to change my C# app properties from building for Any CPU to x64 in the project properties build page.
But then the GUI designer did not show dialogs any more.

The alternative was to use the 32bit Sync Framework and set Prefer 32bit in the build settings of the project.

like image 41
juergen d Avatar answered Oct 20 '22 08:10

juergen d


If it happens in a computer different to your dev machine, be sure you have installed the Microsoft Sync Framework - Redistributable Package. https://www.microsoft.com/en-us/download/details.aspx?id=19502

And choose the right the platform in the download options (x86-x64)

like image 2
Mario M. Avatar answered Oct 20 '22 08:10

Mario M.