locked
ArgumentException error on syncAgent.Syncronise RRS feed

  • Question

  • Hi All,

     

    Wonder if anybody has any insight on this issues I am having with a proof of concept.

     

    I have a SyncProvider WCF service that is hosted inside the Visual Studio 2008 WCF Test Client which I can consume and syncronise to using the Sync Services for ADO v2 on the desktop but when I try to consume the same service from the NetCFSvcUtil generated proxy I get an ArgumentException error.

     

    The device operating system is Windows CE5 and it has the correct "Sync Services for devices" references. It is trying to syncronise a SQL2000 table to a SQLCE3.5 table on the device. I can see the service from the device as I have used Internet Explorer and I am able to navigate to the endpoint at http://120-1496-ROC:8080/SyncServicesTest/Windows/Service/

     

    Code Snippet
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

     

    'Sync With The Server

    Dim _syncAgent As New ClientSyncAgent

    _syncAgent.ClientSyncAgent()

    _syncAgent.Synchronize()

    End Sub

     

    Public Class ClientSyncAgent

    Inherits SyncAgent

     

    Public Sub ClientSyncAgent()

    Me.LocalProvider = New SqlCeClientSyncProvider("Data Source=\Program Files\CE5\JCB_PARCEL_SYSTEM.sdf;Max Database Size=2047", True)

    Me.Configuration.SyncTables.Add("tblEmployee")

    Me.Configuration.SyncTables("tblEmployee").SyncDirection = Data.SyncDirection.Bidirectional

    Me.Configuration.SyncTables("tblEmployee").CreationOption = TableCreationOption.UploadExistingOrCreateNewTable

    Me.RemoteProvider = New Global.Microsoft.Synchronization.Data.ServerSyncProviderProxy(New SyncTestSyncContractClient)

    End Sub

    End Class

     

     

     

    I get the ArgumentExecption error on the .Synchronize with the call stack below.

     

    Code Snippet

       at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess, StackCrawlMark& stackMark)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
       at Microsoft.Synchronization.Data.ServerSyncProviderProxy.GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession)
       at Microsoft.Synchronization.SyncAgent.DownloadChanges(SyncGroupMetadata groupMetadata)
       at Microsoft.Synchronization.SyncAgent.Synchronize()
       at CE5.Form1.Button2_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 CE5.Form1.Main()

     

     

    If I was to guess I would say it was an issue with the RemoteProvider line but i am not sure what the problem is.

     

    Thanks for your help

     

    Phil

    • Moved by Hengzhe Li Friday, April 22, 2011 2:51 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Tuesday, September 23, 2008 3:02 PM

Answers

All replies

  • Phil,

    this exception is thrown during the interaction between your client side proxy and the WCF service. You will need to enable "ShowExceptionDetailinFaults" option on your WCF service so you can see why the service is throwing that exception. Please share the contract interface if you are unable to debug the server error.

    Tuesday, September 23, 2008 5:31 PM
    Moderator
  • Thanks mahjayar,

     

    The service debug was already set to includeExceptionDetailInFaults = True and thats when I get the argument exception.

     

    I think the error is on the client side proxy and is caused by a problem with the remote provider. From what I can see in the stack trace it is not calling into the channel stack to contact the service which makes me think that it is a client proxy issue.

     

    I will post the code below.

     

    Phil

    Wednesday, September 24, 2008 8:10 AM
  • CLIENT SIDE

     

    Cant post the generated client proxy as its to big

     

    User Interface Code Snippet

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

    'Sync With The Server

    Dim _syncAgent As New GENPROXYClientSyncAgent

    Try

    _syncAgent.ClientSyncAgent()

    _syncAgent.Synchronize()

    Catch ex As Exception

    Stop

    End Try

    LoadData()

    End Sub

     

    Code Snippet

    Imports Microsoft.Synchronization

    Imports Microsoft.Synchronization.Data

    Imports Microsoft.Synchronization.Data.SqlServerCe

     

    Public Class GENPROXYClientSyncAgent

    Inherits SyncAgent

     

    Public Sub ClientSyncAgent()

     

    Me.LocalProvider = New SqlCeClientSyncProvider("Data Source=\Program Files\CE5\JCB_PARCEL_SYSTEM.sdf;Max Database Size=2047", True)

     

    Me.Configuration.SyncTables.Add("tblEmployee")

    Me.Configuration.SyncTables("tblEmployee").SyncDirection = Data.SyncDirection.Bidirectional

    Me.Configuration.SyncTables("tblEmployee").CreationOption = TableCreationOption.UploadExistingOrCreateNewTable

    Me.RemoteProvider = New Global.Microsoft.Synchronization.Data.ServerSyncProviderProxy(New SyncTestSyncContractClient)

     

    End Sub

     

    End Class

     

     
    Wednesday, September 24, 2008 8:12 AM
  •  

    SERVER SIDE

     

    Code Snippet

    <?xml version="1.0" encoding="utf-8" ?>

    <configuration>

    <configSections>

    </< FONT>configSections>

    <connectionStrings>

    <add name="WCFService.My.MySettings.ServerJCB_PARCEL_SYSTEMConnectionString"

    connectionString="Data Source=ROCSQL03;Initial Catalog=JCB_PARCEL_SYSTEM;Integrated Security=True"

    providerName="System.Data.SqlClient" />

    </< FONT>connectionStrings>

    <system.web>

    <compilation debug="true" />

    </< FONT>system.web>

    <system.serviceModel>

    <services>

    <service name="WCFService.SyncTestSyncService" behaviorConfiguration="WCFService.SyncTestSyncService">

    <host>

    <baseAddresses>

    <add baseAddress="http://120-1496-ROC:8080/SyncServicesTest/Windows/Service/" />

    </< FONT>baseAddresses>

    </< FONT>host>

    <endpoint address="" binding="basicHttpBinding" contract="WCFService.ISyncTestSyncContract">

    </< FONT>endpoint>

    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>

    </< FONT>service>

    </< FONT>services>

    <behaviors>

    <serviceBehaviors>

    <behavior name="WCFService.SyncTestSyncService">

    <serviceMetadata httpGetEnabled="True"/>

    <serviceDebug includeExceptionDetailInFaults="True" />

    </< FONT>behavior>

    </< FONT>serviceBehaviors>

    </< FONT>behaviors>

    </< FONT>system.serviceModel>

    </< FONT>configuration>

     

     

    SyncTest.Server.SyncContract.vb

    Imports System

    Imports System.Data

    Imports System.Collections.ObjectModel

    Imports System.ServiceModel

    Imports Microsoft.Synchronization.Data

    Partial Public Class SyncTestSyncService

    Inherits Object

    Implements ISyncTestSyncContract

    Private _serverSyncProvider As SyncTestServerSyncProvider

    Public Sub New()

    MyBase.New

    Me._serverSyncProvider = New SyncTestServerSyncProvider

    End Sub

    <System.Diagnostics.DebuggerNonUserCodeAttribute()> _

    Public Overridable Function ApplyChanges(ByVal groupMetadata As SyncGroupMetadata, ByVal dataSet As DataSet, ByVal syncSession As SyncSession) As SyncContext Implements ISyncTestSyncContract.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 ISyncTestSyncContract.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 ISyncTestSyncContract.GetSchema

    Return Me._serverSyncProvider.GetSchema(tableNames, syncSession)

    End Function

    <System.Diagnostics.DebuggerNonUserCodeAttribute()> _

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

    Return Me._serverSyncProvider.GetServerInfo(syncSession)

    End Function

    End Class

    <ServiceContractAttribute()> _

    Public Interface ISyncTestSyncContract

    <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

    <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

    End Interface

     

     

     

    Wednesday, September 24, 2008 8:15 AM
  • It would seem that the problem was in the NetCFSvcUtil generated client proxy where a number of shared types were causing mis-matches against the compact framework versions. For me this is a bug with NetCFSvcUtil

     

    The workaround is explained in this thread

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3488973&SiteID=1

     

    Thanks for all your help.

     

    Phil

     

    Wednesday, September 24, 2008 12:16 PM
  • hi Phil,

    I think u have to modify the getschema function

    folllowing is the code i have used in my application which is in C#.....

    [System.Diagnostics.

    DebuggerNonUserCodeAttribute()]

     

    public virtual SyncSchema GetSchema(string[] tableNames, SyncSession syncSession)

    {

     

    Collection<string> tableCollection = new Collection<string>(tableNames);

     

    return this._serverSyncProvider.GetSchema(tableCollection, syncSession);

    }

    hope this will help u!

    JAI HO!

    Wednesday, July 1, 2009 9:55 AM