locked
Sync Framework CTP 2.0 Object Reference not set to an instance of an object on calling SynchOrchestrator.Synchonize() RRS feed

  • Question

  • ·         I have modified WebSharingAppDemo to use sqlexpress as client in hub-n-spoke scenario. I am using sqlent server.The process exports the schema from server to client but at synchronize call following exception is thrown

    Exception Message - Object reference not set to an instance of an object.
    at Microsoft.Synchronization.Data.RelationalSyncProvider.ResetProviderState(DbSyncScopeMetadata scopeMetadata, DataSet dataSet, DbSyncSession DbSyncSession)
       at Microsoft.Synchronization.Data.RelationalSyncProvider.GetChanges(DbSyncScopeMetadata scopeMetadata, DbSyncSession DbSyncSession, UInt32 memoryBatchSize)
       at Microsoft.Synchronization.Data.RelationalSyncProvider.GetChangeBatch(UInt32 batchSize, SyncKnowledge destinationKnowledge, Object& changeDataRetriever)
       at Microsoft.Synchronization.KnowledgeProviderProxy.GetChangeBatch(UInt32 dwBatchSize, ISyncKnowledge pSyncKnowledge, ISyncChangeBatch& ppChangeBatch, Object& ppUnkDataRetriever)

    I drilled down to the particular method ResetProviderState with the help of reflector. But the issue is in the call to the ResetProviderState method in GetChanges(DbSyncScopeMetadata scopeMetadata, DbSyncSession DbSyncSession, UInt32 memoryBatchSize) which does not have any try catch block so it is not throwing the exact exception with which we could have a clear idea about what is going wrong.

    I am using SqlSyncProvider for client. I have verified that all the necessary properties of the local provider, remote provider (DbSyncProvider) are supplied to the SyncOrchestrator. 

    Is there anything I am missing ?

    • Moved by Max Wang_1983 Thursday, April 21, 2011 10:43 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Friday, October 30, 2009 1:23 PM

Answers

  • Hi,

    It is nice to know that the RTM sample works for you even after changing it to use SqlSyncProvider. Without knowing more details, I cannot tell what can be wrong to cause this exception. Based on your description, I assume that the exception is thrown from client side not the WCF side. Please enable Tracing as I mentioned in the previous email and share it to us. It will help us to understand what had happened.

    Thanks,
    Dong
    This posting is provided AS IS with no warranties, and confers no rights.
    Wednesday, November 4, 2009 6:51 PM
    Moderator

All replies

  • Hi,

    If the SqlSyncProvider.Dispose is called before the GetChanges call, the RestProviderState will throw null reference exception. Can you check if you call SqlSyncProvider.Dispose() in your code changes? One mistake common pattern is:

    1. you create a SqlSyncProvider in WCF service
    2. After the first sync session, the SqlSyncProvider.Dispose is called
    3. You reuse the same proxy instance to start the second sync and this issue will happen.

    In the Database samples for Sync Framework V2 RTM bits: http://code.msdn.microsoft.com/sync. I didn't see SqlSyncProvider.Dispose is called.

    Thanks,
    Dong
    This posting is provided AS IS with no warranties, and confers no rights.
    Friday, October 30, 2009 6:48 PM
    Moderator
  • Hi Dong,

     

    Thanks for the reply !

     

    I have checked my implementation and I haven’t given call to SqlSyncProvider.Dispose() anywhere.

    About  the mistake pattern you mentioned,  

    1.    you create a SqlSyncProvider in WCF service – I am not creating an instance in WCF service

    2.    After the first sync session, the SqlSyncProvider.Dispose is called  - There are no references for Dispose() call.

    3.    You reuse the same proxy instance to start the second sync and this issue will happen. – The Synchronization is failing for first sync also

     

    Are there any other patterns to check for errors ? Am I missing something ?

    Monday, November 2, 2009 12:13 PM
  • Hi,

    Since you mentioned that the remote sync provider is DbSyncProvider, it sounds to me that you are still using the MSFv2.0 CTP2 sample. The MSFv2.0 RTM is available, please try with the RTM samples instead: http://code.msdn.microsoft.com/sync. The remote sync provider is SqlSyncProvider in RTM bits. It may be a bug that we have fixed in RTM.

    Also, if you still see this issue with the RTM bits. Please enable tracing and share us the logs. here are the links for how to enable tracing: http://msdn.microsoft.com/en-us/library/cc807160(SQL.105).aspx.


    Thanks,
    Dong
    This posting is provided AS IS with no warranties, and confers no rights.
    Tuesday, November 3, 2009 1:25 AM
    Moderator
  • Hi Dong,

    Thanks for your reply !

    My application is running fine with sync 1.0. We are using background threads (instances of BackgroundWorker class) for synchronization and keeping UI updated with sync progress status. We are passing 1 table per thread for synchronization in 1.0 implementation. Now we wish to migrate the app. to sync 2.0.

    As suggested above, the sample websharingappdemo (RTM) works fine with us, we modified it to use SqlSyncProvider at both client and server end. But as we integrate it to our application it throws the above mentioned exception. Is it because of the background threads used in the application ? Is there any other way to keep UI refreshed with sync progress status other than using BackgroundWorker threads?

    Wednesday, November 4, 2009 9:52 AM
  • Hi,

    It is nice to know that the RTM sample works for you even after changing it to use SqlSyncProvider. Without knowing more details, I cannot tell what can be wrong to cause this exception. Based on your description, I assume that the exception is thrown from client side not the WCF side. Please enable Tracing as I mentioned in the previous email and share it to us. It will help us to understand what had happened.

    Thanks,
    Dong
    This posting is provided AS IS with no warranties, and confers no rights.
    Wednesday, November 4, 2009 6:51 PM
    Moderator