locked
Generic Error after Drop and Recreate SQL Server CE database RRS feed

  • Question

  • Any idea what is going on here?  Looks like the framework is having trouble recreating the tables in the database.   I am using WCF in the middle and I have wrapped the proxies with a streaming implementation.

    Code:

    using (SqlCeConnection clientConn = new SqlCeConnection(global::Protiviti.Construct.DataService.Properties.Settings.Default.ClientProtivitiConstructDatabaseConnectionString))
    {
    	if (File.Exists(clientConn.Database))
    	{
    		File.Delete(clientConn.Database);
    	}
    }
    
    SqlCeEngine sqlCeEngine = new SqlCeEngine(global::Protiviti.Construct.DataService.Properties.Settings.Default.ClientProtivitiConstructDatabaseConnectionString);
    sqlCeEngine.CreateDatabase();
    
    ProtivitiConstructLocalDataCacheSyncAgent syncAgent = new ProtivitiConstructLocalDataCacheSyncAgent();
    Microsoft.Synchronization.Data.SqlServerCe.SqlCeClientSyncProvider localProvider = (Microsoft.Synchronization.Data.SqlServerCe.SqlCeClientSyncProvider)syncAgent.LocalProvider;
    localProvider.ConflictResolver.StoreErrorAction = Microsoft.Synchronization.Data.ResolveAction.ServerWins;
    localProvider.SyncProgress += new EventHandler<SyncProgressEventArgs>(localProvider_SyncProgress);
    Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize();
    


    Error:

    System.ArgumentException occurred
      Message="Object of type 'System.String[]' cannot be converted to type 'System.Collections.ObjectModel.Collection`1[System.String]'."
      Source="mscorlib"
      StackTrace:
           at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
           at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
           at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
           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.GetSchema(Collection`1 tableNames, SyncSession syncSession)
           at Microsoft.Synchronization.SyncAgent.InitClientSchema()
           at Microsoft.Synchronization.SyncAgent.Synchronize()
           at Protiviti.Construct.DataService.DataService.ReinitializeDatabase() in D:\Projects\SolutionsPortal\Trunk\Protiviti.Construct\Desktop\Protiviti.Construct.DataService\DataService.cs:line 625
      InnerException:
    • Moved by Max Wang_1983 Thursday, April 21, 2011 12:39 AM forum consolidation (From:SyncFx - Technical Discussion [ReadOnly])
    Tuesday, July 28, 2009 8:14 PM

Answers

  • Turns out the clien side ServerSyncProviderProxy had the TableNames input set as a Collection<string>.  Changed it to string[] to match how the SyncAgent wanted to call it and it worked.
    Wednesday, July 29, 2009 6:59 PM

All replies

  • Turns out the clien side ServerSyncProviderProxy had the TableNames input set as a Collection<string>.  Changed it to string[] to match how the SyncAgent wanted to call it and it worked.
    Wednesday, July 29, 2009 6:59 PM
  • Hello,

    I am having the same trouble. I did check the Reference.cs file, but the GetSchema method is fine there..takes array as the parameter. Which additional file should I check.
    Thanks
    Monday, September 14, 2009 9:30 PM
  • Tim -
    Our code has changed a lot since I posted this (and we have moved away from streaming) so it is difficult for me to specifically recreate/remember this.  If you are using streaming then your web service auto generated proxy in the Reference.cs class will have streams as the inputs and outputs.  This means you should have created a Proxy for this in your client side code that translates the Agent calls into the stream calls.  My problem was that the input parameters in my proxy that I created for the Agent had the wrong type of input (Collection<string> instead of string[] or the other way around) for the GetSchema method.  You just need to switch the data type until you make the agent happy.
    Hopefully this helps!
    Stewart

    PS - I might have had it backward in my last post.  It might be that you need to have the input as a Collection<string>.  If so, in the Configure Service Reference window (right click Service Reference) try changing the Collection type option to System.Collections.ObjectModel.Collection.  This should force the service reference to auto generate a proxy that uses Collection<string> instead of string[].
    Wednesday, September 16, 2009 3:14 AM