المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : XmlSerializer doesn't serialize properties when inheriting List? [modified]



C# Programming
02-18-2010, 06:40 PM
Hi folks!

The XmlSerializer is giving me a headache. I've got this class (.NET 2.0):
[Serializable]
public class ParticipantList : List
{
private Guid _ID = Guid.NewGuid();
public Guid ID
{
get { return _ID; }
set { _ID = value; }
}

public static void ToFile(ParticipantList list, string filename)
{
using (FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write))
{
XmlSerializer xs = new XmlSerializer(typeof(ParticipantList));
xs.Serialize(fs, list);
}
}

public static ParticipantList FromFile(string filename)
{
using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
XmlSerializer xs = new XmlSerializer(typeof(ParticipantList));
return (ParticipantList)xs.Deserialize(fs);
}
}
}
Pretty basic stuff it would seem.
The participant list gets serialized OK, but the ID isn't included in the XML file!http://www.barakasoft.com/script/Forums/Images/smiley_frown.gif
Did I miss something? Has the XmlSerializer gone nuts?

Thanks in advance for tips on how to get the ID serialized as well!

[Update]
No additional property or member gets serialized, the Guid isn't the reason.Regards,
mav

--
Black holes are the places where God divided by 0... modified on Wednesday, February 17, 2010 6:16 AM