Hi everyone,
I have run out of ideas on this one.
We are using SyncFramework to sync our application with Microsoft Exchange 2010. I use the SyncFolderItems method to get the changes and then use the SyncState that is returned as the Anchor. The SyncState is large string that I convert to bytes and
pass to ReportChanges. When the SyncState gets over approximately 8000 bytes it throws an out of range exception. From the stack trace it appears to come from a private method called ValidateAnchor.
There is no documentation regarding limits on the Anchor size, and regardless I do not know of any other Anchor I can use with Exchange Web Services.
Can anyone enlighten me on what exactly ReportChanges is doing and/or any limitations on the Anchor size?
Here is more information in case it helps. Thanks in advance!
Here is the Code Snippet:
public override void EnumerateChanges(byte[] anchor, AnchorEnumerationContext context)
{
//context.SetDeleteMode(SimpleSyncProviderDeleteMode.LocalOnly);
ChangePack changePack = null;
changePack = anchor == null ? FullyEnumerate() : GetChanges(anchor);
_anchor = changePack.Anchor;
context.ReportChanges(
changePack.Changes,
changePack.Anchor);
}
In GetChanges we call:
var exChangeList = exchangeService.SyncFolderItems(
new FolderId(folder),
PropertySet.FirstClassProperties,
null,
512,
SyncFolderItemsScope.NormalItems,
fromState);
Finally the Anchor in ChangePack is set here:
Anchor = Encoding.UTF8.GetBytes(exChangeList.SyncState)
Here is the Error and Stack Trace:
System.ArgumentOutofRangeException Parameter Name anchor
at Microsoft.Synchronization.SimpleProviders.Utility.ValidateAnchor(Byte[] anchor)
at Microsoft.Synchronization.SimpleProviders.AnchorEnumerationContext.AllocateUnmanagedAnchor(Byte[] anchor, Int32& anchorLength)
at Microsoft.Synchronization.SimpleProviders.AnchorEnumerationContext.ReportChanges(IEnumerable`1 itemChanges, Byte[] updatedAnchor)
at LexisNexis.PM.Synchronization.Exchange.Providers.BaseProvider`2.EnumerateChanges(Byte[] anchor, AnchorEnumerationContext context) in C:\Dev\ExSync\LexisNexis.PM.Synchronization.Exchange\LexisNexis.PM.Synchronization.Exchange\Providers\BaseProvider.cs:line
308
at Microsoft.Synchronization.SimpleProviders._AnchorEnumerationSimpleSyncProviderProxy.EnumerateChanges(Byte[] pAnchor, UInt32 cbAnchor, IAnchorChangeDetectionCallback pCallback)
at Microsoft.Synchronization.CoreInterop.ISyncSession.Start(CONFLICT_RESOLUTION_POLICY resolutionPolicy, _SYNC_SESSION_STATISTICS& pSyncSessionStatistics)
at Microsoft.Synchronization.KnowledgeSyncOrchestrator.DoOneWaySyncHelper(SyncIdFormatGroup sourceIdFormats, SyncIdFormatGroup destinationIdFormats, KnowledgeSyncProviderConfiguration destinationConfiguration, SyncCallbacks DestinationCallbacks,
ISyncProvider sourceProxy, ISyncProvider destinationProxy, ChangeDataAdapter callbackChangeDataAdapter, SyncDataConverter conflictDataConverter, Int32& changesApplied, Int32& changesFailed)
at Microsoft.Synchronization.KnowledgeSyncOrchestrator.DoOneWayKnowledgeSync(SyncDataConverter sourceConverter, SyncDataConverter destinationConverter, SyncProvider sourceProvider, SyncProvider destinationProvider, Int32& changesApplied, Int32&
changesFailed)
at Microsoft.Synchronization.KnowledgeSyncOrchestrator.Synchronize()
at Microsoft.Synchronization.SyncOrchestrator.Synchronize()
at LexisNexis.PM.Synchronization.Exchange.Service.Sync.SyncManager.Sync(SyncProvider exProvider, SyncProvider provider, SyncDirection syncDirection) in C:\Dev\ExSync\LexisNexis.PM.Synchronization.Exchange\LexisNexis.PM.Synchronization.Exchange.Service\Sync\SyncManager.cs:line
545
at LexisNexis.PM.Synchronization.Exchange.Service.Sync.SyncManager.Sync(IUser user, IUserOptions options, SyncDirection dir, String metadataPath, Func`4 exProviderFactory, IEnumerable`1 factories) in C:\Dev\ExSync\LexisNexis.PM.Synchronization.Exchange\LexisNexis.PM.Synchronization.Exchange.Service\Sync\SyncManager.cs:line
432