Problem deserializing when using Chrome but not IE8

Problem deserializing when using Chrome but not IE8

Old forum URL: forums.lhotka.net/forums/t/9377.aspx


saggett posted on Monday, August 16, 2010

I've just deployed a new version of my site, now using Silverlight 4.0, .NET 4.0 and CSLA 4.0. However I'm getting a deserialization error when accessing the site via Chrome 5 but not when accessing it via IE8:

There was an error deserializing the object of type System.Collections.Generic.List`1[[Csla.Serialization.Mobile.SerializationInfo, Csla, Version=4.0.0.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30]]. The input source is not correctly formatted.

   at TreeBrowser.SilverlightLib.Cache.ReadOnlyLineagesCache.Client_FetchLineagesCompleted(Object sender, DataPortalResult`1 e)

   at Csla.DataPortal`1.OnFetchCompleted(DataPortalResult`1 e)

   at Csla.DataPortal`1.proxy_FetchCompleted(Object sender, DataPortalResult`1 e)

   at Csla.DataPortalClient.WcfProxy`1.OnFetchCompleted(DataPortalResult`1 e)

   at Csla.DataPortalClient.WcfProxy`1.proxy_FetchCompleted(Object sender, FetchCompletedEventArgs e)

   at Csla.WcfPortal.WcfPortalClient.OnFetchCompleted(Object state)

I'm using basic http binding, like so:

            var bhb = new BasicHttpBinding

                {

                    Name = "BasicHttpBinding_IWcfPortal",

                    MaxBufferSize = 10000000,

                    MaxReceivedMessageSize = 10000000

                };

            bhb.Security.Mode = BasicHttpSecurityMode.None;

            Csla.DataPortalClient.WcfProxy.DefaultBinding = bhb;

Strangely I never got this exception in my development environment, even when calling the live WCF service from local code.

The problem site is live at www.religionstree.com, if you want you can browse to it with both IE and Chrome to see what I mean.

cds replied on Monday, August 16, 2010

HI Stephen

I just tried your site from IE8 and get an error - do you have the CrossDomain.xml and ClientAccessPolicy.xml files deployed in the root directory of your site?

That seems to be the problem from what I can see in your error message.

Craig

cds replied on Monday, August 16, 2010

OK, I just had a look at your site again - the problem seems to be that your WcfPortal.svc is in a sub-folder - TreeBrowser.Silverlight.WebApplication - and that's where you'd need to deploy the CrossDomain.xml and ClientAccessPolicy.xml files.

When I try accessing them from your root they work fine, but in the sub-folder I get a 404.

 

Craig

saggett replied on Monday, August 16, 2010

TreeBrowser.Silverlight.WebApplication is the subfolder of my local dev WCF service, it was still configured to call that instead of the live web service, so it was working locally but not anywhere else. Embarassing to find, simple to fix, but unfortunately it's still having issues.

Having corrected the WCF service path it's reverted to the error given above ("There was an error deserializing the object of type System.Collections.Generic.List`1[[Csla.Serialization.Mobile.SerializationInfo, Csla, Version=4.0.0.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30]]"). However that's only on Chrome. IE gives:

 

Can not register property Id after containing type (ReadOnlyLineage) has been instantiated

   at TreeBrowser.SilverlightLib.Cache.ReadOnlyLineagesCache.Client_FetchLineagesCompleted(Object sender, DataPortalResult`1 e)

   at Csla.DataPortal`1.OnFetchCompleted(DataPortalResult`1 e)

   at Csla.DataPortal`1.proxy_FetchCompleted(Object sender, DataPortalResult`1 e)

   at Csla.DataPortalClient.WcfProxy`1.OnFetchCompleted(DataPortalResult`1 e)

   at Csla.DataPortalClient.WcfProxy`1.proxy_FetchCompleted(Object sender, FetchCompletedEventArgs e)

   at Csla.WcfPortal.WcfPortalClient.OnFetchCompleted(Object state)

 

The code by which this property is registered is as follows:

private static PropertyInfo<int> IdProperty = RegisterProperty<int>(typeof(ReadOnlyLineage), new PropertyInfo<int>("Id", "Id", 0));

Which I believe is correct, plus I've never encountered this exception locally.

I'm thinking of trying out the various serialization configuration options to fix it but that would be very much a trial and error thing when I don't understand the root cause.

Thanks for your help, it's much appreciated.

saggett replied on Monday, August 16, 2010

I've just been running Fiddler on the requests to http://www.religionstree.com/wcfportal.svc and got the full exception stack:

 

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><FetchResponse xmlns="http://ws.lhotka.net/WcfDataPortal"><FetchResult xmlns:a="http://schemas.datacontract.org/2004/07/Csla.Server.Hosts.Silverlight" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><a:ErrorData><a:ExceptionTypeName>System.Runtime.Serialization.SerializationException</a:ExceptionTypeName><a:InnerError><a:ExceptionTypeName>System.Xml.XmlException</a:ExceptionTypeName><a:InnerError i:nil="true"/><a:Message>The input source is not correctly formatted.</a:Message><a:Source>System.Runtime.Serialization</a:Source><a:StackTrace>   at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)&#xD;

   at System.Xml.XmlBufferReader.ReadValue(XmlBinaryNodeType nodeType, ValueHandle value)&#xD;

   at System.Xml.XmlBinaryReader.ReadNode()&#xD;

   at System.Xml.XmlBinaryReader.Read()&#xD;

   at System.Xml.XmlBaseReader.IsStartElement()&#xD;

   at System.Xml.XmlBaseReader.IsStartElement(XmlDictionaryString localName, XmlDictionaryString namespaceUri)&#xD;

   at System.Runtime.Serialization.XmlReaderDelegator.IsStartElement(XmlDictionaryString localname, XmlDictionaryString ns)&#xD;

   at System.Runtime.Serialization.XmlObjectSerializer.IsRootElement(XmlReaderDelegator reader, DataContract contract, XmlDictionaryString name, XmlDictionaryString ns)&#xD;

   at System.Runtime.Serialization.DataContractSerializer.InternalIsStartObject(XmlReaderDelegator reader)&#xD;

   at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName, DataContractResolver dataContractResolver)&#xD;

   at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)</a:StackTrace><a:TargetSiteName>ThrowXmlException</a:TargetSiteName></a:InnerError><a:Message>There was an error deserializing the object of type System.Collections.Generic.List`1[[Csla.Serialization.Mobile.SerializationInfo, Csla, Version=4.0.0.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30]]. The input source is not correctly formatted.</a:Message><a:Source>System.Runtime.Serialization</a:Source><a:StackTrace>   at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)&#xD;

   at System.Runtime.Serialization.DataContractSerializer.ReadObject(XmlReader reader)&#xD;

   at Csla.Serialization.Mobile.MobileFormatter.Deserialize(XmlReader reader) in C:\Visual Studio Projects\csla\40\Source\Csla\Serialization\Mobile\MobileFormatter.cs:line 278&#xD;

   at Csla.Serialization.Mobile.MobileFormatter.Deserialize(Stream serializationStream) in C:\Visual Studio Projects\csla\40\Source\Csla\Serialization\Mobile\MobileFormatter.cs:line 249&#xD;

   at Csla.Serialization.Mobile.MobileFormatter.Deserialize(Byte[] data) in C:\Visual Studio Projects\csla\40\Source\Csla\Serialization\Mobile\MobileFormatter.cs:line 434&#xD;

   at Csla.Server.Hosts.Silverlight.WcfPortal.Fetch(CriteriaRequest request) in C:\Visual Studio Projects\csla\40\Source\Csla\Server\Hosts\Silverlight\WcfPortal.cs:line 95</a:StackTrace><a:TargetSiteName>ReadObjectHandleExceptions</a:TargetSiteName></a:ErrorData><a:GlobalContext i:nil="true"/><a:ObjectData i:nil="true"/></FetchResult></FetchResponse></s:Body></s:Envelope>

 

 

The exception occurs when going from remotely hosted silverlight to remotely hosted service, but not locally hosted silverlight to remote service.

It looks like when loading the same page with IE8 it successfully deserializes the data of several requests but then fails later on with the "cannot register property" error.

 

saggett replied on Monday, August 16, 2010

Just to see what would happen I tried switching UseBinaryXML off. Now I get this instead (on Chrome, no change on IE8):

 

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><FetchResponse xmlns="http://ws.lhotka.net/WcfDataPortal"><FetchResult xmlns:a="http://schemas.datacontract.org/2004/07/Csla.Server.Hosts.Silverlight" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><a:ErrorData><a:ExceptionTypeName>System.IO.FileLoadException</a:ExceptionTypeName><a:InnerError i:nil="true"/><a:Message>Could not load file or assembly 'Csla, Version=3.7.0.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)</a:Message><a:Source>mscorlib</a:Source><a:StackTrace>   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)&#xD;

   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark&amp; stackMark, Boolean loadTypeFromPartialName)&#xD;

   at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark&amp; stackMark)&#xD;

   at System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)&#xD;

   at Csla.Reflection.MethodCaller.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) in C:\Visual Studio Projects\csla\40\Source\Csla\Reflection\MethodCaller.cs:line 147&#xD;

   at Csla.Reflection.MethodCaller.GetType(String typeName) in C:\Visual Studio Projects\csla\40\Source\Csla\Reflection\MethodCaller.cs:line 166&#xD;

   at Csla.Serialization.Mobile.MobileFormatter.GetTypeFromCache(String typeName) in C:\Visual Studio Projects\csla\40\Source\Csla\Serialization\Mobile\MobileFormatter.cs:line 224&#xD;

   at Csla.Serialization.Mobile.MobileFormatter.DeserializeAsDTO(List`1 deserialized) in C:\Visual Studio Projects\csla\40\Source\Csla\Serialization\Mobile\MobileFormatter.cs:line 295&#xD;

   at Csla.Serialization.Mobile.MobileFormatter.Deserialize(List`1 data) in C:\Visual Studio Projects\csla\40\Source\Csla\Serialization\Mobile\MobileFormatter.cs:line 453&#xD;

   at Csla.Serialization.Mobile.MobileFormatter.Deserialize(XmlReader reader) in C:\Visual Studio Projects\csla\40\Source\Csla\Serialization\Mobile\MobileFormatter.cs:line 279&#xD;

   at Csla.Serialization.Mobile.MobileFormatter.Deserialize(Stream serializationStream) in C:\Visual Studio Projects\csla\40\Source\Csla\Serialization\Mobile\MobileFormatter.cs:line 249&#xD;

   at Csla.Serialization.Mobile.MobileFormatter.Deserialize(Byte[] data) in C:\Visual Studio Projects\csla\40\Source\Csla\Serialization\Mobile\MobileFormatter.cs:line 434&#xD;

   at Csla.Server.Hosts.Silverlight.WcfPortal.GetCriteria(Byte[] criteriaData) in C:\Visual Studio Projects\csla\40\Source\Csla\Server\Hosts\Silverlight\WcfPortal.cs:line 214&#xD;

   at Csla.Server.Hosts.Silverlight.WcfPortal.Fetch(CriteriaRequest request) in C:\Visual Studio Projects\csla\40\Source\Csla\Server\Hosts\Silverlight\WcfPortal.cs:line 89</a:StackTrace><a:TargetSiteName>GetTypeByName</a:TargetSiteName></a:ErrorData><a:GlobalContext i:nil="true"/><a:ObjectData i:nil="true"/></FetchResult></FetchResponse></s:Body></s:Envelope>

I've no idea why it's looking for CSLA v3.7.0.0, I've checked each of my projects and the configs thoroughly and all references are to 4.0.0, all deployed CSLA binaries are 4.0.0. I'm so confused.

saggett replied on Tuesday, August 17, 2010

'Could not load file or assembly 'Csla, Version=3.7.0.0' was caused by the Silverlight execution choosing to use an old version of the CSLA dll instead of the new version included in the xap. Clearing the browser cache fixed it, so the site is now up and running with UseBinaryXML set to false. Switching it back on causes the original error ("There was an error deserializing the object of type System.Collections.Generic.List`1[[Csla.Serialization.Mobile.SerializationInfo, Csla, Version=4.0.0.0, [...]]. The input source is not correctly formatted.") to occur on both IE8 and Chrome.

 

So in summary, the site had two errors, the cross-domain error (caused by a misconfigured service path) and an old version of CSLA sticking around in the browser cache (fixed by clearing the cache). After implementing both of these fixes the serialization succeeds with UseBinaryXML = false, but fails with UseBinaryXML = true, and then only on the deployed site.

Copyright (c) Marimer LLC