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
GPGurucharan Patwal Syncfusion Team December 5, 2003 03:22 PM
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 :
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.
RMRoland MartinDecember 5, 2003 07:10 PM
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.
HPHolger PerschDecember 7, 2003 10:44 PM
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.