locked
The given key was not present in the dictionary. SyncFx 2.1 RRS feed

  • Question

  •  I'm getting The given key was not present in the dictionary. exception sometimes while syncing.

    I'm using VS.net 2010 , SQL 2008 as Server db & SqlCe 3.5 Sp1 for the client db.

    I have looked through web & generally they relate this problem with Visual studio not properly installed.

    I'm not sure weather that's the reason here but according to stack trace it looks like something to do with Microsoft.Synchronization.Data.SqlServer - ApplyBulkChanges method.

    Stack trace is as follow:

    at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at Microsoft.Synchronization.Data.SqlServer.SqlChangeHandler.ApplyBulkChanges(DataTable dataTable)
       at Microsoft.Synchronization.Data.RelationalSyncProvider.ApplyChangesInternal(DbSyncScopeMetadata scopeMetadata, IDbTransaction transaction, FailedDeleteDelegate_type failedDeleteDelegate, DataSet dataSet, ChangeApplicationType applyType)
       at Microsoft.Synchronization.Data.RelationalSyncProvider.ApplyChanges(DbSyncScopeMetadata scopeMetadata, IDbTransaction applyTransaction, DataSet dataSet, DbSyncSession DbSyncSession, Boolean commitTransaction, FailedDeleteDelegate_type failedDeleteDelegate, String batchFileName, ChangeApplicationAction& action)
       at Microsoft.Synchronization.Data.RelationalSyncProvider.SingleTransactionApplyChangesAdapter.Apply(DataSet dataSet, Boolean commitTransaction, FailedDeleteDelegate_type failedDeleteDelegate, String batchFileName, ChangeApplicationAction& action)
       at Microsoft.Synchronization.Data.RelationalSyncProvider.ApplyChanges(DbSyncScopeMetadata scopeMetadata, DataSet dataSet, DbSyncSession dbSyncSession, Boolean commitTransaction)
       at Microsoft.Synchronization.Data.RelationalSyncProvider.ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, Object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics)
       at Ryarc.WebSyncContract.RelationalWebSyncService.ApplyChanges(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, Object changeData) in C:\Users\jimmys\Documents\Visual Studio 2010\Projects\Ryarc.WebSyncContract\RelationalWebSyncService.cs:line 111
       at SyncInvokeApplyChanges(Object , Object[] , Object[] )
       at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
       at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

    Any help would be apreciated.

    -Vishal

     

     

    Friday, December 3, 2010 3:26 AM

All replies

  • have you tried enabling Sync Fx tracing just in case it gives out more information on the whats going on?
    Friday, December 3, 2010 8:42 AM
  • I have resolved this problem by turning on the batching in syncing.

    but batching sometime gives following problem :

    System.InsufficientMemoryException was unhandled by user code
      Message=Failed to allocate a managed memory buffer of 67108864 bytes. The amount of available memory may be low.
      Source=mscorlib
      StackTrace:
        Server stack trace:
           at System.Runtime.Fx.AllocateByteArray(Int32 size)
           at System.Runtime.InternalBufferManager.PooledBufferManager.TakeBuffer(Int32 bufferSize)
           at System.ServiceModel.Channels.BufferManager.WrappingBufferManager.TakeBuffer(Int32 bufferSize)
           at System.ServiceModel.Channels.HttpInput.GetMessageBuffer()
           at System.ServiceModel.Channels.HttpInput.ReadBufferedMessage(Stream inputStream)
           at System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(Exception& requestException)
           at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
           at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
           at System.ServiceModel.Channels.ClientReliableChannelBinder`1.RequestClientReliableChannelBinder`1.OnRequest(TRequestChannel channel, Message message, TimeSpan timeout, MaskingMode maskingMode)
           at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode)
           at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout)
           at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.Request(Message message, TimeSpan timeout)
           at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
           at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
           at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
           at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
           at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
        Exception rethrown at [0]:
           at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
           at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

     

    I have set up the tracelog as mentioned in this article.

    http://msdn.microsoft.com/en-us/library/ee617387.aspx

    But can't find anything special in the log which indicates what's wrong while syncing ?

          

    • Proposed as answer by Ganeshan Thursday, December 9, 2010 5:52 PM
    Tuesday, December 7, 2010 10:13 PM
  • the error you have above is more of a WCF error than Sync Fx. you may want to check your WCF settings and adjust them accordingly (based on your error, it looks like your buffer setting is more than what the available memory)
    • Proposed as answer by Ganeshan Thursday, December 9, 2010 5:53 PM
    Tuesday, December 7, 2010 11:18 PM