I’m serializing a list of ObservableCollection<MyType> using this line of code and it works fine:
var serializer = new SharpSerializer(true);
serializer.Serialize(myList, myStreamObject);
The problem occurs when I try to deserialize my data.
var serializer = new SharpSerializer(true);
this.items = (ObservableCollection<MyType>)serializer.Deserialize(
myStreamObject);
When I debug the return type of serializer.Deserialize(myStreamObject) is:
System.Collections.ObjectModel.ObservableCollection`1[MyNameSpace.MyType]
Thereby resulting in typecast error? How do I solve this problem? What am I doing wrong when deserializing?
Thanks
I don’t know if you’re using
SharpSerializerfor Silverlight or for the full .NETAs default
SharpSerializerserializes data as short type name. It could be the most probable reason of your error. Try to serialize your data as anAssemblyFullQualifiedName: