locked
Problem Synchronizing Local DB & Remote DB RRS feed

  • Question

  •  

    hi.....

    I am developing an Occassionally Connected Smart Device Application using the following:

     

    Visual Studio 2008 SP 1

    SQL Server 2005

    SQL Server Compact 3.5 SP1

     

    I am following the Occassionally Connected Smart Device Application Sample as provided In MSDN.I am facing the following problem. 

     

    Problem:

    On Clicking the Synchronization Button i am Calling the following code:

    -------------------------------------------------------------------------------------------------------------------------------------------

    ' The service reference

    Dim webSvcProxy = New WebRefService.Service1()

    ' The server provider

    Dim serverProvider = New Microsoft.Synchronization.Data.ServerSyncProviderProxy(webSvcProxy)

    ' The sync agent

    Dim syncAgent = New LocalDataCache1SyncAgent()

    syncAgent.RemoteProvider = serverProvider

    syncAgent.Products.SyncDirection = Microsoft.Synchronization.Data.SyncDirection.Bidirectional

    ' Synchronize the databases

    Facing Problem here..

    **********************************

    Dim stats = syncAgent.Synchronize

    *********************************

    ' Reload the DataSet/Datagrid from the local database

    ProductsTableAdapter.Fill(Me.CybermaxMobileDataSet.Products)

    ' Show synchronization statistics

    MessageBox.Show("Changes Downloaded: " + stats.TotalChangesDownloaded.ToString() + _

    vbCrLf + "Changes Uploaded: " + stats.TotalChangesUploaded.ToString())

    -----------------------------------------------------------------------------------------------------------------------------------------------

    • I am getting the following error when i insert new record and synchronize it.....
    • ApplyChanges method not found on proxy instance.
    • And i get the following error when i make changes in my Remote Database i.e on server and then click on Synchronize button.
    • GetChanges method not found on proxy instance.

     

    Please note that my data is properly cached in local database of the device.

     

    Hoping for a quick reply.........

     

    Thanks

     

     

     

    • Moved by Max Wang_1983 Thursday, April 21, 2011 10:45 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Friday, November 28, 2008 11:50 AM

Answers

  • hi, i have the same problem,

    its caused due to app.conig file.

    you need to change:

    "endpoint" to:

    <

     

    endpoint address="" binding="basicHttpBinding" contract="MiddleTirSevLibary.IXXXCacheSyncContract">


    the "IXXXCacheSyncContract" is interface class that your XXX.SyncContract.cs file contain
    Tuesday, November 3, 2009 5:39 PM

All replies

  • Did you define a service contract containing these methods and do you have an interface implementation?
    Your service should look like this

    Service contract
    ///  Access server sync parameters
    [OperationContract]
    public SyncServerInfo GetServerInfo(
    SyncSession syncSession);

    /// Access table schema in DataSet form   
    [OperationContract]
    public SyncSchema GetSchema(Collection<string> tableNames, SyncSession syncSession);

    /// Enumerate group changes   
    [OperationContract]
    public SyncContext GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession);

    /// Apply group changes
    [OperationContract]
    public SyncContext ApplyChanges(SyncGroupMetadata groupMetadata, DataSet dataSet, SyncSession   syncSession);


    Implementation:

    ///
      Access server sync parameters
    public SyncServerInfo GetServerInfo(
    SyncSession syncSession)
    {
        return _serverProvider.GetServerInfo(
    syncSession);

    /// Access table schema in DataSet form   
    public SyncSchema GetSchema(Collection<string> tableNames,
    SyncSession syncSession)
    {
        return _serverProvider.GetSchema(tableNames,
    syncSession);

    /// Enumerate group changes   
    public SyncContext GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession)
    {
        return _serverProvider.GetChanges(groupMetadata, syncSession);       
    }

    /// Apply group changes
    public SyncContext ApplyChanges(SyncGroupMetadata groupMetadata, DataSet dataSet, SyncSession   syncSession)
    {               
        return _serverProvider.ApplyChanges(groupMetadata, dataSet, syncSession);
    }   


    Friday, November 28, 2008 7:28 PM
  •  

    Im experiencing the same problem although its in relation to the "GETSCHEMA" method.

     

    {"GetSchema method not found on proxy instance."}

     

    Somebody please HELP

     

    One thing i should mention is that these methods were not created for me. When i added the WCF to my project only the

    "GETDATA" and "GetDataUsingDataContract" methods were created.

     

    StackTrace:

       at Microsoft.Synchronization.Data.ServerSyncProviderProxy.GetSchema(Collection`1 tableNames, SyncSession syncSession)    at Microsoft.Synchronization.SyncAgent.InitClientSchema()    at Microsoft.Synchronization.SyncAgent.Synchronize()    at WQASmartDevice.NewCustomer.NewMenuItemMenuItem1_Click(Object sender, EventArgs e)    at System.Windows.Forms.MenuItem.OnClick(EventArgs e)    at System.Windows.Forms.Menu.ProcessMnuProc(Control ctlThis, WM wm, Int32 wParam, Int32 lParam)    at System.Windows.Forms.Form.WnProc(WM wm, Int32 wParam, Int32 lParam)    at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)    at Microsoft.AGL.Forms.EVL.EnterModalDialog(IntPtr hwnModal)    at System.Windows.Forms.Form.ShowDialog()    at WQASmartDevice.MainPage.Button1_Click(Object sender, EventArgs e)    at System.Windows.Forms.Control.OnClick(EventArgs e)    at System.Windows.Forms.Button.OnClick(EventArgs e)    at System.Windows.Forms.ButtonBase.WnProc(WM wm, Int32 wParam, Int32 lParam)    at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)    at Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)    at System.Windows.Forms.Application.Run(Form fm)    at WQASmartDevice.MainPage.Main()

     

    Code Snippet

    Public Class WQASyncService

    Implements WQASyncContract

     

    Public Function GetData(ByVal value As Integer) As String Implements WQASyncContract.GetData

    Return String.Format("You entered: {0}", value)

    End Function

    Public Function GetDataUsingDataContract(ByVal composite As CompositeType) As CompositeType Implements WQASyncContract.GetDataUsingDataContract

    If composite.BoolValue Then

    composite.StringValue = (composite.StringValue & "Suffix")

    End If

    Return composite

    End Function

    Public Function GetSchema(ByVal tableNames As Collection(Of String), ByVal syncSession As SyncSession) As SyncSchema Implements WQASyncContract.GetSchema

    Return Me.GetSchema(tableNames, syncSession)

    End Function

    Public Function GetChanges(ByVal groupMetadata As SyncGroupMetadata, ByVal syncSession As SyncSession) As SyncContext Implements WQASyncContract.GetChanges

    Return Me.GetChanges(groupMetadata, syncSession)

    End Function

    Public Function ApplyChanges(ByVal groupMetadata As SyncGroupMetadata, ByVal dataSet As DataSet, ByVal syncSession As SyncSession) As SyncContext Implements WQASyncContract.ApplyChanges

    Return Me.ApplyChanges(groupMetadata, dataSet, syncSession)

    End Function

    Public Function GetServerInfo(ByVal syncSession As SyncSession) As SyncServerInfo Implements WQASyncContract.GetServerInfo

    Return Me.GetServerInfo(syncSession)

    End Function

     

    Code Snippet

    <ServiceContract()> _

    Public Interface WQASyncContract

     

    <OperationContract()> _

    <XmlSerializerFormat()> _

    Function GetSchema(ByVal tableNames As Collection(Of String), ByVal syncSession As SyncSession) As SyncSchema

     

    <OperationContract()> _

    <XmlSerializerFormat()> _

    Function GetServerInfo(ByVal syncSession As SyncSession) As SyncServerInfo

     

    <OperationContract()> _

    <XmlSerializerFormat()> _

    Function ApplyChanges(ByVal groupMetadata As SyncGroupMetadata, ByVal dataSet As DataSet, ByVal syncSession As SyncSession) As SyncContext

     

    <OperationContract()> _

    <XmlSerializerFormat()> _

    Function GetChanges(ByVal groupMetadata As SyncGroupMetadata, ByVal syncSession As SyncSession) As SyncContext

     

     

    Ben.
    Tuesday, December 2, 2008 4:13 AM
  • San007, can you show me the code behind your SyncService and you SyncContract?

     

    Ben.

     

    Tuesday, December 2, 2008 5:27 AM
  • Can you post your proxy code?

    Also can you list how you generated the proxy code? SvcUtil/VS?

     

    Tuesday, December 2, 2008 8:59 PM
    Moderator
  • Hi Mahjayar, i used Visual Studio 2008 to generate the service reference.

     

    This is only part of the proxy code, let me know if you require more.

     

    Thanks Ben.

     

    Code Snippet

    Option Strict On

    Option Explicit On

    Imports System.Data

    Namespace ServiceReference

    <System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0"), _

    System.ServiceModel.ServiceContractAttribute(ConfigurationName:="ServiceReference.WQASyncContract")> _

    Public Interface WQASyncContract

    <System.ServiceModel.OperationContractAttribute(Action:="http://tempuri.org/WQASyncContract/GetSchema", ReplyAction:="http://tempuri.org/WQASyncContract/GetSchemaResponse"), _

    System.ServiceModel.XmlSerializerFormatAttribute()> _

    Function GetSchema(ByVal tableNames() As String, ByVal syncSession As ServiceReference.SyncSession) As ServiceReference.SyncSchema

    <System.ServiceModel.OperationContractAttribute(Action:="http://tempuri.org/WQASyncContract/GetServerInfo", ReplyAction:="http://tempuri.org/WQASyncContract/GetServerInfoResponse"), _

    System.ServiceModel.XmlSerializerFormatAttribute()> _

    Function GetServerInfo(ByVal syncSession As ServiceReference.SyncSession) As ServiceReference.SyncServerInfo

    <System.ServiceModel.OperationContractAttribute(Action:="http://tempuri.org/WQASyncContract/ApplyChanges", ReplyAction:="http://tempuri.org/WQASyncContract/ApplyChangesResponse"), _

    System.ServiceModel.XmlSerializerFormatAttribute()> _

    Function ApplyChanges(ByVal groupMetadata As ServiceReference.SyncGroupMetadata, ByVal dataSet As System.Data.DataSet, ByVal syncSession As ServiceReference.SyncSession) As ServiceReference.SyncContext

    <System.ServiceModel.OperationContractAttribute(Action:="http://tempuri.org/WQASyncContract/GetChanges", ReplyAction:="http://tempuri.org/WQASyncContract/GetChangesResponse"), _

    System.ServiceModel.XmlSerializerFormatAttribute()> _

    Function GetChanges(ByVal groupMetadata As ServiceReference.SyncGroupMetadata, ByVal syncSession As ServiceReference.SyncSession) As ServiceReference.SyncContext

    <System.ServiceModel.OperationContractAttribute(Action:="http://tempuri.org/WQASyncContract/GetData", ReplyAction:="http://tempuri.org/WQASyncContract/GetDataResponse"), _

    System.ServiceModel.XmlSerializerFormatAttribute()> _

    Function GetData(ByVal value As Integer) As String

    <System.ServiceModel.OperationContractAttribute(Action:="http://tempuri.org/WQASyncContract/GetDataUsingDataContract", ReplyAction:="http://tempuri.org/WQASyncContract/GetDataUsingDataContractResponse"), _

    System.ServiceModel.XmlSerializerFormatAttribute()> _

    Function GetDataUsingDataContract(ByVal composite As ServiceReference.CompositeType) As ServiceReference.CompositeType

    End Interface

     

     

    Tuesday, December 2, 2008 11:39 PM
  • hi pips06...

    My Code for:

    -------------------------------------------------

    Code behind SyncService:

     

    Public Class Service1

    Implements IService1

    Public Function GetData(ByVal value As Integer) As String Implements IService1.GetData

    Return String.Format("You entered: {0}", value)

    End Function

    Public Function GetDataUsingDataContract(ByVal composite As CompositeType) As CompositeType Implements IService1.GetDataUsingDataContract

    If composite.BoolValue Then

    composite.StringValue = (composite.StringValue & "Suffix")

    End If

    Return composite

    End Function

    End Class

    ---------------------------------------

    Code behind SyncContract:

    Imports System

    Imports System.Data

    Imports System.Collections.ObjectModel

    Imports System.ServiceModel

    Imports Microsoft.Synchronization.Data

     

    Partial Public Class Service1

    Inherits Object

    Implements ILocalDataCache1SyncContract

    Private _serverSyncProvider As LocalDataCache1ServerSyncProvider

    Public Sub New()

    MyBase.New()

    Me._serverSyncProvider = New LocalDataCache1ServerSyncProvider

    End Sub

    <System.Diagnostics.DebuggerNonUserCodeAttribute()> _

    Public Overridable Function ApplyChanges(ByVal groupMetadata As SyncGroupMetadata, ByVal dataSet As DataSet, ByVal syncSession As SyncSession) As SyncContext Implements ILocalDataCache1SyncContract.ApplyChanges

    Return Me._serverSyncProvider.ApplyChanges(groupMetadata, dataSet, syncSession)

    End Function

    <System.Diagnostics.DebuggerNonUserCodeAttribute()> _

    Public Overridable Function GetChanges(ByVal groupMetadata As SyncGroupMetadata, ByVal syncSession As SyncSession) As SyncContext Implements ILocalDataCache1SyncContract.GetChanges

    Return Me._serverSyncProvider.GetChanges(groupMetadata, syncSession)

    End Function

    <System.Diagnostics.DebuggerNonUserCodeAttribute()> _

    Public Overridable Function GetSchema(ByVal tableNames As Collection(Of String), ByVal syncSession As SyncSession) As SyncSchema Implements ILocalDataCache1SyncContract.GetSchema

    Return Me._serverSyncProvider.GetSchema(tableNames, syncSession)

    End Function

    <System.Diagnostics.DebuggerNonUserCodeAttribute()> _

    Public Overridable Function GetServerInfo(ByVal syncSession As SyncSession) As SyncServerInfo Implements ILocalDataCache1SyncContract.GetServerInfo

    Return Me._serverSyncProvider.GetServerInfo(syncSession)

    End Function

    End Class

    <ServiceContractAttribute()> _

    <XmlSerializerFormat()> _

    Public Interface ILocalDataCache1SyncContract

    <OperationContract()> _

    Function ApplyChanges(ByVal groupMetadata As SyncGroupMetadata, ByVal dataSet As DataSet, ByVal syncSession As SyncSession) As SyncContext

    <OperationContract()> _

    Function GetChanges(ByVal groupMetadata As SyncGroupMetadata, ByVal syncSession As SyncSession) As SyncContext

    <OperationContract()> _

    Function GetSchema(ByVal tableNames As Collection(Of String), ByVal syncSession As SyncSession) As SyncSchema

    <OperationContract()> _

    Function GetServerInfo(ByVal syncSession As SyncSession) As SyncServerInfo

    End Interface

    -------------------------------------------------

     

    If you need something other than that...then plz inform me........this problem is gettin over me now ......

     

    Thanks

     

     

     

     

    Wednesday, December 3, 2008 6:41 AM
  • Hi master..,
    Do you know whether there is no synccontract although I have created wcf and local database cache?

    Thanks
     =)
    Friday, April 24, 2009 12:04 PM
  • hi, i have the same problem,

    its caused due to app.conig file.

    you need to change:

    "endpoint" to:

    <

     

    endpoint address="" binding="basicHttpBinding" contract="MiddleTirSevLibary.IXXXCacheSyncContract">


    the "IXXXCacheSyncContract" is interface class that your XXX.SyncContract.cs file contain
    Tuesday, November 3, 2009 5:39 PM