locked
Serialization Error when ApplyChanges is called -> SqlServerCE to SqlServer2008 + WCF RRS feed

  • Question

  • I get the error message below and cant figure out how to fix it. Please help.

    Solution is SqlServer CE Desktop (client), SqlServer 2008 (server). Syncing over WCF using the new DB specific sync providers. Binding is set to NetTcpBinding with no security. All of my other calls to other portions of my web service work fine. Other calls to the SyncProvider and SyncProviderProxy work as well such as Initialize, GetScopeDescription. My code actually connects through all of this and will pull the schema down and create a new SqlServerCE DB but when I call the SyncOperationStatistics stats = orchestrator.Synchronize(); call it errors out. More specifically below....

    I get this error when the code line below is called inside of the ProcessChangeBatch function.

    stats = this.proxy.ApplyChanges(resolutionPolicy, sourceChanges, changeDataRetriever);

    The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:changeData. The InnerException message was 'There was an error deserializing the object of type System.Object. '?^[N' contains invalid UTF8 bytes.'.  Please see InnerException for more details.


    Server stack trace:
       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
       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)
       at PXS.CloudContract.IPXSCloudStorageSync.ApplyChanges(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, Object changeData)
       at PXS.CloudContract.PXSCloudStorageSyncProviderProxy.ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, Object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics) in C:\PlatinumXunSolutions\PXS\PXS.CloudContract\PXSCloudStorageSyncProviderProxy.cs:line 218
    Saturday, January 2, 2010 12:08 AM

Answers

  • Hi Reginald,

    Indeed, you use the code server side. Did you use the method on the SyncContext object that is returned from the ApplyChanges method?

            public override SyncContext ApplyChanges(SyncGroupMetadata groupMetadata, DataSet dataSet, SyncSession syncSession)
            {
                SyncContext result = provider.ApplyChanges(groupMetadata, dataSet, syncSession);
                ValidateSerialization(result);
                return result;
            }
    Monday, January 11, 2010 1:53 PM

All replies

  • Hi Reginald,

    I have seen this error as well. To get more information on what does not serialize well, add this code to the Server-side logic. And call it in your WCF service operation.
    [Conditional("DEBUG")]
    private static void ValidateSerialization(object result)
    {
        try
        {
            System.Xml.Serialization.XmlSerializer serializer =
               new System.Xml.Serialization.XmlSerializer(result.GetType());
            serializer.Serialize(new MemoryStream(), result);
        }
        catch (System.Exception ex)
        {
            Debug.WriteLine(ex.ToString());
        }
    }
    
    • Proposed as answer by Rudi - Euricom Wednesday, January 6, 2010 12:35 PM
    Monday, January 4, 2010 4:15 PM
  • where do I call this in my server side code? is this called right before I return any results to the client?
    Sunday, January 10, 2010 3:33 PM
  • I ran it on the server side and called it on the objects that get passed to ApplyChanges. All validates and no errors. And the code actually works a few times something like 3 times but then throws the same error on the client side when trying to deserialize the xml. FYI, I know it says see InnerException but the InnerException is null so no more info there.


    Error Msg:
    The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:changeData. The InnerException message was 'There was an error deserializing the object of type System.Object. '����' contains invalid UTF8 bytes.'.  Please see InnerException for more details.


    Server stack trace:
       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
       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)
       at PXS.CloudContract.IPXSCloudStorageSync.ApplyChanges(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, Object changeData)
       at PXS.CloudContract.PXSCloudStorageSyncProviderProxy.ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, Object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics) in C:\PlatinumXunSolutions\PXS\PXS.CloudContract\PXSCloudStorageSyncProviderProxy.cs:line 218
    Monday, January 11, 2010 1:10 AM
  • Hi Reginald,

    Indeed, you use the code server side. Did you use the method on the SyncContext object that is returned from the ApplyChanges method?

            public override SyncContext ApplyChanges(SyncGroupMetadata groupMetadata, DataSet dataSet, SyncSession syncSession)
            {
                SyncContext result = provider.ApplyChanges(groupMetadata, dataSet, syncSession);
                ValidateSerialization(result);
                return result;
            }
    Monday, January 11, 2010 1:53 PM