Deserializing a costum ListViewItem obj
I have this class:
Code:
class Toy : ListViewItem
{
//costum attributes
//constructor (this has to be like this so it can deserialize)
public Toy(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
but then when I deserialize all my costum attributes are lost... What I'm I doing wrong?
Thank you very much (sorry for making so many questions o this foruns xD)
Re: Deserializing a costum ListViewItem obj
Be sure to also add the default constructor besides the constructor for the IDeserialization interface.
Re: Deserializing a costum ListViewItem obj
ok I think I got it but I'm getting and error if I have a subclass parent with the toy
Code:
class Toy : ListViewItem, ISerializable
{
//something here
}
class Car : Toy , ISerializable
{
//something here
}
class Bike : Toy , ISerializable
{
//Something here
}
I've created the Iserializable methods getobjectdata(...)
when serializing a Toy it's okay... when serializing a Car or Bike, Exception error :S:S
Re: Deserializing a costum ListViewItem obj
Even Better!! Is there a way to remove the Iserializable attribute from a parent class?? my big problem is that ListViewItem is ISerializable.... but I want to remove this!! Is this possible? please tell me that it is! lool XD
Re: Deserializing a costum ListViewItem obj
Try using the Serializable attribute
Code:
[Serializable]
class Toy : ListViewItem
{
}
Re: Deserializing a costum ListViewItem obj
Re: Deserializing a costum ListViewItem obj
You also need to put the appropriate xmlserialization attributes on the public properties of your class.
Btw, deriving from ListViewItem may not work because the ListViewItem itself may not be serializable.