I am trying to store data in a compressed state in IsolatedStorage
Deseializing gives me the following error but I can't see why? I followed the code through Serialize and it creates a SerializationInfo per element + 1.
"Error in line 1 position 2. Expecting element 'ArrayOfSerializationInfo' from namespace 'http://schemas.datacontract.org/2004/07/Csla.Serialization.Mobile'..
Encountered 'Element' with name 'ArrayOfNameValueListBase.NameValuePairOfintstringzwHo_PEFv', namespace 'http://schemas.datacontract.org/2004/07/Csla'."
" at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName)
at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName)
at System.Runtime.Serialization.DataContractSerializer.ReadObject(XmlReader reader)
at Csla.Serialization.Mobile.MobileFormatter.Deserialize(XmlReader reader)
at Csla.Serialization.Mobile.MobileFormatter.Deserialize(Stream serializationStream)
at Csla.Serialization.Mobile.MobileFormatter.Deserialize(Byte[] data)
at ICSharpCode.SharpZipLib.Wrapper.Deserialize(Type t, Byte[] objectData)
at ICSharpCode.SharpZipLib.Wrapper.DecompressAndDeserialize(Type t, Byte[] bytData)
at XXX.Business.BusinessClasses.ClassificationsLookup.GetClassifications(EventHandler`1 handler)"
Thanks for the advice. Having looked at the bloat produced by MobileFormatter.Serialize I agree. However, using MobileFormatter takes care of all business base properties. If I was to populate my BO from a file format of my own choosing (something that has better storage characteristics) I wouldn't be sure what I need to set/call in terms of base class. I have the 2005 and 2008 books so if you knew where I should look to find out that would be great.
FYI I am using SharpZipLib to cut down on the size of the serialised data.
IsolatedStorageFile
.GetUserStoreForSite andIsolatedStorageFile
.GetUserStoreForApplicationAutoComplete is a mixed blessing ;)
davido:If I was to populate my BO from a file format of my own choosing (something that has better storage characteristics) I wouldn't be sure what I need to set/call in terms of base class. I have the 2005 and 2008 books so if you knew where I should look to find out that would be great.
CSLA defines a persistence model through the data portal. My recommendation would be to use that persistence model, so you'd persist your data using DataPortal_XYZ or object factory methods.
Remember that the data portal is invoked from your factory method (or BeginSave(), which you can override). So you can put code in those methods to check first and see if there's a client cache, ensuring you go to the server only if there isn't a client cache.
If there is a client cache you can still call the data portal, just call it in local mode.
Hopefully this makes sense. What I am saying is that you can implement both server-side and client-side persistence models, and your factory method can decide whether to have the data portal call the server (for server-side persistence) or local (for client-side persistence).
This way your client-side persistence can store just the object data, and you don't need to worry about the metadata (like IsNew, etc) because that'll get set appropriately based on your normal DataPortal_XYZ methods.
Copyright (c) Marimer LLC