locked
ReplicaMetadata.GetLocalVersions throws NullReferenceException - why? RRS feed

  • Question

  • Greetings,

    I have a custom KnowledgeSyncProvider and I'm using SqlMetadataStore to track item metadata.

    The scenario is that the same item exists on both sides of a Sync session, but the two peers have not synchronized before, and therefore don't know that this item is the same. When the source ChangeBatch is sent to the destination, I call ReplicaMetadata.GetLocalVersions() on it and the ReplicaMetadata instance throws a NullReferenceException. I can't see why this is at all. When I look in the metadata datafile, I notice that the metadata is there with the same SyncGlobalId.

    Why would this exception be thrown? Is it just masking the real issue?

    • Moved by Max Wang_1983 Wednesday, April 20, 2011 11:18 PM Forum consolidation (From:SyncFx - Technical Discussion [ReadOnly])
    Wednesday, November 4, 2009 1:55 AM

Answers

  • Ok, I figured this out.

    Apparently, it is the same root cause as this user discovered in another method: http://social.microsoft.com/Forums/en-US/synctechnicaldiscussion/thread/e69c9e47-8672-4005-b386-78a02af4fe55

    There is a bug in the ReplicaMetadata.CreateItemMetadata() where the ChangedVersion isn't set on the created item metadata, and when it is saved, the provider sets the UpdatePeer columns to NULL, which then throws the NullReferenceException. The solution is to manually set the ChangeVersion property on the ItemMetadata instance before saving it to the ReplicaMetadata.
    • Marked as answer by codekaizen Wednesday, November 4, 2009 8:03 PM
    Wednesday, November 4, 2009 8:03 PM