Microsoft Sync Framework COM class error
Asked Answered
N

4

16

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

Norge answered 25/1, 2013 at 10:11 Comment(6)
shouldn't the reference assemblies be in Program Files instead of Program Files (x86)? are you running it in IIS or the VS web server?Solifidian
I tried both. If I add these references via the VS add-reference, it comes from Program Files (x86)\Microsoft SDKs\Microsoft Sync Framework\2.1\Runtime. I manually deleted the "Program Files (x86)" one and added new one with browsing from C:\Program Files\Microsoft Sync Framework\2.1\Runtime\x64. Same result....Norge
VS 2012 shows and adds "Microsoft.Synchronization" assembly from "Program Files (x86)" but instead of that if I manually add assembly from "C:\Program Files\Microsoft Sync Framework\2.1\Runtime\x64" , i get "Could not load file or assembly 'DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format." error.Norge
is your IIS running in 64-bit?Solifidian
yes it is on the same OS which is "Windows 7 Home Prem. (x64)". Assemblies work on WindowsForms App. and Console App. properly but the asp.net.Norge
if i start the project without debugging(ctrl+F5) it works and syncs the databases..Norge
N
16

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

Norge answered 28/1, 2013 at 18:45 Comment(0)
H
4

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.

Hittel answered 23/9, 2015 at 21:54 Comment(0)
B
2

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)

Bier answered 26/4, 2016 at 9:35 Comment(0)
R
0

If you do not want to change your target platform and want to keep it "Any". Use a new application pool for your application,go to advance settings and change Enable 32-bit application as True. It worked for me, it may work for you.

enter image description here

Rubi answered 22/8, 2016 at 5:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.