none
ClientProvider cast error RRS feed

  • Question

  • Dear all,

    I have a class which inherits from "Microsoft.Synchronization.Data.SqlServerCe.SqlCeClientSyncProvider"

     

    public partial class CS_SyncProvider : Microsoft.Synchronization.Data.SqlServerCe.SqlCeClientSyncProvider
        {
            public CS_SyncProvider()
            {
                this.ConnectionString = ("Data Source="
                            + (System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase), "CoffeeStreet.sdf") + ";Max Database Size=2047"));
            }
    
            public CS_SyncProvider(string connectionString)
            {
                this.ConnectionString = connectionString;
            }
        }

     

    I have another class which inherits Microsoft.Synchronization.SyncAgent

     

     public partial class CS_SyncAgent : Microsoft.Synchronization.SyncAgent

     


    When I try to create the localprovider in the syncAgent using the previous SQLServerCEClientSyncProvider, I get an "Cast Exception Error".

     

    public CS_SyncAgent()
            {
                Microsoft.Synchronization.Data.SqlServerCe.SqlCeClientSyncProvider prov = new CS_SyncProvider();
                this.LocalProvider = prov;
                //this.InitializeSyncProviders();
                this.InitializeSyncTables();
                this.OnInitialized();
            }
    The "invalid cast Exception" is on the "this.localProvider = prov" .. and it's a "Microsoft.Synchronization.Data.ClientSyncProvider

     

     

    Details: 

     

    L'exception System.InvalidCastException n'a pas été gérée
      Message="Microsoft.Synchronization.Data.ClientSyncProvider"
      Source="Microsoft.Synchronization.Data"
      StackTrace:
           à Microsoft.Synchronization.SyncAgent.set_LocalProvider(SyncProvider value)
           à ConsoleApplication1.CS_SyncAgent..ctor() dans C:\Users\Sylvain\Documents\Visual Studio 2008\Projects\TestCSSyncService\ConsoleApplication1\SyncAgent.cs:ligne 58
           à ConsoleApplication1.Program.Main(String[] args) dans C:\Users\Sylvain\Documents\Visual Studio 2008\Projects\TestCSSyncService\ConsoleApplication1\Program.cs:ligne 18
           à System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           à System.Threading.ThreadHelper.ThreadStart()
      InnerException: 
    

     


    If someone has an idea ...

    Thanks

    Sylvain


    • Edited by Sylvain_D Thursday, December 22, 2011 4:28 PM
    Thursday, December 22, 2011 4:27 PM

All replies