locked
Sync 2.0 RTM ChangeBatch is not serializable RRS feed

  • Question

  • I am using Sync 2.0 RTM and WCF service to perform the synchronization but I am getting the following error
    To be XML serializable, types which inherit from IEnumerable must have an implementation of Add(System.Object) at all levels of their inheritance hierarchy. Microsoft.Synchronization.ChangeBatch does not implement Add(System.Object). 
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
    
    Exception Details: System.InvalidOperationException: To be XML serializable, types which inherit from IEnumerable must have an implementation of Add(System.Object) at all levels of their inheritance hierarchy. Microsoft.Synchronization.ChangeBatch does not implement Add(System.Object).
    
    Source Error: 
    
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  
    
    Stack Trace: 
    
    
    [InvalidOperationException: To be XML serializable, types which inherit from IEnumerable must have an implementation of Add(System.Object) at all levels of their inheritance hierarchy. Microsoft.Synchronization.ChangeBatch does not implement Add(System.Object).]
       System.Xml.Serialization.TypeScope.GetEnumeratorElementType(Type type, TypeFlags& flags) +904588
       System.Xml.Serialization.TypeScope.ImportTypeDesc(Type type, MemberInfo memberInfo, Boolean directReference) +3937467
       System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference, Boolean throwOnError) +151
       System.Xml.Serialization.XmlReflectionImporter.ImportMemberMapping(XmlReflectionMember xmlReflectionMember, String ns, XmlReflectionMember[] xmlReflectionMembers, Boolean rpc, Boolean openModel, RecursionLimiter limiter) +65
       System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean rpc, Boolean openModel, RecursionLimiter limiter) +236
    
    [InvalidOperationException: There was an error reflecting 'sourceChanges'.]
       System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean rpc, Boolean openModel, RecursionLimiter limiter) +843
       System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(String elementName, String ns, XmlReflectionMember[] members, Boolean hasWrapperElement, Boolean rpc, Boolean openModel, XmlMappingAccess access) +130
       System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(String elementName, String ns, XmlReflectionMember[] members, Boolean hasWrapperElement, Boolean rpc, Boolean openModel) +32
       System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(String elementName, String ns, XmlReflectionMember[] members, Boolean hasWrapperElement, Boolean rpc) +26
       System.ServiceModel.Description.XmlSerializerImporter.ImportMembersMapping(XmlName elementName, String ns, XmlReflectionMember[] members, Boolean hasWrapperElement, Boolean rpc, Boolean isEncoded, String mappingKey) +147
       System.ServiceModel.Description.OperationReflector.ImportMembersMapping(String elementName, String ns, XmlReflectionMember[] members, Boolean hasWrapperElement, Boolean rpc, String mappingKey) +122
       System.ServiceModel.Description.OperationReflector.LoadBodyMapping(MessageDescription message, String mappingKey, MessagePartDescriptionCollection& rpcEncodedTypedMessageBodyParts) +513
       System.ServiceModel.Description.OperationReflector.CreateMessageInfo(MessageDescription message, String key) +361
       System.ServiceModel.Description.OperationReflector.EnsureMessageInfos() +404
       System.ServiceModel.Description.Reflector.EnsureMessageInfos() +90
       System.ServiceModel.Description.OperationReflector.get_Request() +12
       System.ServiceModel.Description.XmlSerializerOperationBehavior.CreateFormatter() +30
       System.ServiceModel.Description.XmlSerializerOperationBehavior.System.ServiceModel.Description.IOperationBehavior.ApplyDispatchBehavior(OperationDescription description, DispatchOperation dispatch) +46
       System.ServiceModel.Description.DispatcherBuilder.BindOperations(ContractDescription contract, ClientRuntime proxy, DispatchRuntime dispatch) +254
       System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) +3724
       System.ServiceModel.ServiceHostBase.InitializeRuntime() +37
       System.ServiceModel.ServiceHostBase.OnBeginOpen() +27
       System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +49
       System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +261
       System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +121
       System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +479
    
    [ServiceActivationException: The service '/EditorSyncService/EditorSyncService.svc' cannot be activated due to an exception during compilation.  The exception message is: There was an error reflecting 'sourceChanges'..]
       System.ServiceModel.AsyncResult.End(IAsyncResult result) +11527290
       System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +194
       System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext) +176
       System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +278
       System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
    Here sourceChanges is nothing but the ChangeBatch instance. I am using WebSharingAppDemo for reference.
    Am I missing something ?
    • Moved by Max Wang_1983 Wednesday, April 20, 2011 11:10 PM Forum consolidation (From:SyncFx - Technical Discussion [ReadOnly])
    Monday, November 16, 2009 11:11 AM

Answers

All replies

  • Can you please share how your WCF contract looks like (only part which has ChangeBatch as the parameter)?

    Thanks,
    Lech
    Monday, November 16, 2009 6:51 PM
  • Hi Lech,

    Thanks for reply !!

    Here is the WCF Contract

    [OperationContract] 
    SyncSessionStatistics ApplyChanges(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeData);

    Here when I give my interface [ServiceKnownType(typeof(ChangeBatch))] it gives me the following error


    To be XML serializable, types which inherit from IEnumerable must have an implementation of Add(System.Object) at all levels of their inheritance hierarchy. Microsoft.Synchronization.ChangeBatch does not implement Add(System.Object). 
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
    
    Exception Details: System.InvalidOperationException: To be XML serializable, types which inherit from IEnumerable must have an implementation of Add(System.Object) at all levels of their inheritance hierarchy.
    Microsoft.Synchronization.ChangeBatch does not implement Add(System.Object). Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and Location of the exception can be identified using the exception stack trace below. Stack Trace: [InvalidOperationException: To be XML serializable, types which inherit from IEnumerable must have an implementation of Add(System.Object) at all levels of their inheritance hierarchy. Microsoft.Synchronization.ChangeBatch does not implement Add(System.Object).] System.Xml.Serialization.TypeScope.GetEnumeratorElementType(Type type, TypeFlags& flags) +904588 System.Xml.Serialization.TypeScope.ImportTypeDesc(Type type, MemberInfo memberInfo, Boolean directReference) +3937467 System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference, Boolean throwOnError) +151 System.Xml.Serialization.ModelScope.GetTypeModel(Type type, Boolean directReference) +83 System.Xml.Serialization.XmlReflectionImporter.IncludeType(Type type, RecursionLimiter limiter) +55 System.Xml.Serialization.XmlReflectionImporter.IncludeType(Type type) +38 System.ServiceModel.Description.OperationReflector.EnsureMessageInfos() +343 System.ServiceModel.Description.Reflector.EnsureMessageInfos() +90 System.ServiceModel.Description.OperationReflector.get_Request() +12 System.ServiceModel.Description.XmlSerializerOperationBehavior.CreateFormatter() +30 System.ServiceModel.Description.XmlSerializerOperationBehavior.System.ServiceModel.Description.IOperationBehavior.ApplyDispatchBehavior(OperationDescription description, DispatchOperation dispatch) +46 System.ServiceModel.Description.DispatcherBuilder.BindOperations(ContractDescription contract, ClientRuntime proxy, DispatchRuntime dispatch) +254 System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) +3724 System.ServiceModel.ServiceHostBase.InitializeRuntime() +37 System.ServiceModel.ServiceHostBase.OnBeginOpen() +27 System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +49 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +261 System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +121 System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +479 [ServiceActivationException: The service '/EditorSyncService/EditorSyncService.svc' cannot be activated due to an exception during compilation. The exception message is: To be XML serializable, types which inherit from IEnumerable must have an implementation of Add(System.Object) at all levels of their inheritance hierarchy.
    Microsoft.Synchronization.ChangeBatch does not implement Add(System.Object)..] System.ServiceModel.AsyncResult.End(IAsyncResult result) +11527290 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +194 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext) +176 System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +278 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

    I am using [XmlSerializerFormat] for my ServiceContract. Is it causing this perticular issue ?
    Am I missing something here ?
    Tuesday, November 17, 2009 7:01 AM
  • Hey,
    Can you please check what fundamentally different (in the WCF area) are you doing comparing to the sample:
    http://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=sync&ReleaseId=3421

    Thanks,
    Lech
    Tuesday, November 17, 2009 9:01 PM
  • Hi Lech ,

    Thanks for reply !!

    I have gone through the example suggested by you . It seems fine .

    I have implemented WCF service for v1.0 and I have used Microsoft.Synchronization.Data.ServerSyncProviderProxy instance as my remote provider.
    But in Sync 2.0 RTM , I am not able to find out any server proxy class to implement the methods that SqlSyncProvider(my remote provider) provides.

    Now I want to migrate my WCF service to the v2.0 to improve batching.

    Is there anything available in Sync 2.0 RTM as wrapper for server proxy similar to a class in v1.0 like Microsoft.Synchronization.Data.ServerSyncProviderProxy in order to create a remote proxy? Am I missing something basic here ?


    Wednesday, November 18, 2009 11:31 AM
  • Currently XML Serializable using WCF is not fully supported. You wil have to use binary serialization when using WCF. Any reason you want to stick to XML serialization?


    jandeepc
    Saturday, November 21, 2009 12:16 AM