locked
N-tier sync using WCF & DbPeerSyncProvider RRS feed

  • Question

  •  

    I got this error while calling the Syncronize().  The error happens while reading GetScope() method from service.  The tracer show the following message. 

    There was an error while trying to serialize parameter http://tempuri.org/:GetScopeResult. The InnerException message was 'Type 'Microsoft.Synchronization.SyncId' with data contract name 'SyncId:http://schemas.datacontract.org/2004/07/Microsoft.Synchronization' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'.  Please see InnerException for more details.

     

    My code looks something like this

    INTERFACE CODE:

    [ServiceContract]

    public interface ISyncService

    {

    [OperationContract]

    SyncContext GetChanges(SyncScopeMetadata scopeMetadata, SyncSession syncSession);

    [OperationContract]

    SyncContext ApplyChanges(SyncScopeMetadata scopeMetadata, DataSet dataSet, SyncSession syncSession);

    [OperationContract]

    SyncScope GetScope(SyncSession syncSession);

    }

     

    IMPLEMENTATION CODE:

    public class SyncService : ISyncService

    {

    private DbPeerSyncProvider _provider;

    public SyncService()

    {

    _provider = new DbPeerSyncProvider();

    SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();

    builder["Data Source"] = "MACHINENAME";

    builder["integrated Security"] = false;

    builder["user id"] = "user";

    builder["password"] = "password";

    builder["Initial Catalog"] = "remotedb";

    SqlConnection serverConnection = new SqlConnection(builder.ConnectionString);

    _provider.Connection = serverConnection;

    _provider.ScopeName = "test";

    //Setup sync adapter.

    SyncAdapter syncAdapter = new SyncAdapter("mytable");

    //ALL REQUIRED COMMANDS SET HERE...

    }

    #region ISyncService Members

    public SyncContext GetChanges(SyncScopeMetadata scopeMetadata, SyncSession syncSession)

    {

    return _provider.GetChanges(scopeMetadata, syncSession);

    }

    public SyncContext ApplyChanges(SyncScopeMetadata scopeMetadata, DataSet dataSet, SyncSession syncSession)

    {

    return _provider.ApplyChanges(scopeMetadata, dataSet, syncSession);

    }

    public SyncScope GetScope(SyncSession syncSession)

    {

    return _provider.GetScope(syncSession);

    }

    }

     

    FROM THE LOCAL SERVER:

    DbPeerSyncProvider localProvider = new DbPeerSyncProvider();

    try

    {

    PeerSyncProviderProxy proxyLocal = new PeerSyncProviderProxy(AddLocalProvider(localProvider), PeerType.Local);

    proxyLocal.Configuration.ScopeId = scopeId;

    proxyLocal.Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.ApplicationDefined;

    PeerSyncProviderProxy proxyRemote = new PeerSyncProviderProxy(new SyncServiceClient("BasicHttpBinding_ISyncService"),PeerType.Remote);

    proxyRemote.Configuration.ScopeId = scopeId;

    proxyRemote.Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.ApplicationDefined;

    SyncAgent syncAgent = new SyncAgent();

    syncAgent.LocalProvider = proxyLocal;

    syncAgent.RemoteProvider = proxyRemote;

    syncAgent.Direction = SyncDirection.Upload;

    syncStats = syncAgent.Synchronize();

    ShowStatistics(syncStats);

    }

    catch (Exception ex)

    {

    MessageBox.Show(ex.ToString());

    }

    }

     

    I am not pasing all the sync event handler code.

     

    Any help is appricated.

    • Moved by Max Wang_1983 Friday, April 22, 2011 8:38 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Wednesday, February 13, 2008 2:14 PM

Answers

All replies