Muaddib
Muaddib

Reputation: 535

Microsoft sync framework 2.1 ServerSyncProviderProxy with client SQL Server Express

I've been following the tutorial here to configure a proxy service with WCF for synchronization. But all the examples I see the ClientProvider is for SqlServer Compact Edition. Can it be done with the SqlSyncProvider for SQL Server Express?

For example my code is:

var svc = new ServiceForSyncClient();
ServerSyncProvider serverProvider = new ServerSyncProviderProxy(svc);

// create the sync orhcestrator
var syncOrchestrator = new SyncOrchestrator
{
    LocalProvider = new SqlSyncProvider("ProductsScope", clientConn),
    RemoteProvider = serverProvider,
    Direction = SyncDirectionOrder.DownloadAndUpload
};

var syncStats = syncOrchestrator.Synchronize();

But when synchronizing, I get an exception:

An unhandled exception of type 'System.InvalidCastException' occurred in Microsoft.Synchronization.dll

Additional information: Microsoft.Synchronization.KnowledgeSyncProvider

Upvotes: 0

Views: 423

Answers (1)

JuneT
JuneT

Reputation: 7860

you're using two completely different sync providers. part of your code is using the the older offline providers (DBServerSyncProvider and SQLCEClientSyncProvider) and you're trying to use the SQLSyncProvider which is part of the newer knowledge-based/peer-to-peer sync provider (SqlSycProvider/SqlCeSyncProvider).

You can't mix and match the older and newer sync providers

If you want to use SQL Express as the client, here is a sample for using it with WCF

Upvotes: 1

Related Questions