|
-
January 15th, 2010, 05:08 AM
#1
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)
-
January 15th, 2010, 08:21 AM
#2
Re: Deserializing a costum ListViewItem obj
Be sure to also add the default constructor besides the constructor for the IDeserialization interface.
-
January 15th, 2010, 03:42 PM
#3
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
-
January 15th, 2010, 03:56 PM
#4
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
-
January 15th, 2010, 05:05 PM
#5
Re: Deserializing a costum ListViewItem obj
Try using the Serializable attribute
Code:
[Serializable]
class Toy : ListViewItem
{
}
-
January 15th, 2010, 08:17 PM
#6
Re: Deserializing a costum ListViewItem obj
-
January 15th, 2010, 11:20 PM
#7
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.
Last edited by Arjay; January 15th, 2010 at 11:58 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|