We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

AppStateSerializer problem

I am attempting to use AppStateSerializer to save/restore an object. I am using SerializeMode.XMLFile, the serialization works fine but DeserializeObject fails on line 817 of AppSerializer.cs. The source comments say the following: // The depersisted hashtable will contain a string representation of // the XML data. Convert the contents of the String into a bytearray // and deserialize the bytearray using a memorystream. In Visual Studio this is not true, the hashtable contains an already deserialized object, not a String version. The following fails: byte[] bytearray = encoding.GetBytes(ht[strname] as String); Additional information: String reference not set to an instance of a String. Is there anything I can do to fix this? Thanks - Roland

3 Replies

GP Gurucharan Patwal Syncfusion Team December 5, 2003 08:22 PM UTC

Hi Roland, Please take a look at the sample in the folder - ..\Syncfusion\Essential Suite\Shared\Samples\AppStateSerializerDemo which shows how an AppStateSerializer could be used to save/load state information of a control on a form. Refer to this code snippet : AppStateSerializer.InitializeSingleton(SerializeMode.XMLFile, "GlobalState"); Here state information is persisted and loaded from a XMLFile name GlobalState. Please let us know what object (like ToolBars, docking windows etc.) are you referring to here, so that we could send you a specific sample that meets your requirements. Thanks for choosing Syncfusion products. Regards, Guru Patwal Syncfusion, Inc.


RM Roland Martin December 6, 2003 12:10 AM UTC

I am attempting to serialize/deserialize my own object, not dockable window or toolbar state. The object has a few int members. Is the problem that AppStateSerializer only supports simple types and not complex objects? I can serialize/deserialize individual int/string/bool fine, I just cannot deserialize an object with multiple member variables.


HP Holger Persch December 8, 2003 03:44 AM UTC

I have done this already in my project and everything works fine. I am serializing and deserializing a class with about 9 fields in a XML based file (SerializeMode.XMLFile) without any problems. The class contains some strings, bools and also a ArrayList. Regards, Holger

Loader.
Live Chat Icon For mobile
Up arrow icon