Hello,
I am trying to make a custom XMLserializer for my class.
wrote a simple writeXML method for my class and it works.
My class has int members.
However, when I add a member of type datetime, the writeXML doesn't work anymore!
This is the sort of an error i get:
System.InvalidOperationException: There was an error reflecting property 'datetime member'. ---> System.InvalidOperationException: You need to add XmlChoiceIdentifierAttribute to the 'datetime member' member.
here is my code for writeXML:
public void WriteXml(String filePath)
{
StreamWriter stWriter = null;
XmlSerializer xmlSerializer;
xmlSerializer = new XmlSerializer(this.GetType());
stWriter = new StreamWriter(filePath);
System.Xml.Serialization.XmlSerializerNamespaces xs = new XmlSerializerNamespaces();
//To remove namespace and any other inline information tag
xs.Add("", "");
xmlSerializer.Serialize(stWriter, this, xs);
}
here are the attributes i have mentioned for the datetime member of the class:
[System.Xml.Serialization.XmlElementAttribute()]
[XmlElementAttribute(DataType = "date")]
note added: I get similar error for class member of type BOOL
any help would be greatly appreciated.
(I use framework 2, visual studio .net 2005, C#)
I am trying to make a custom XMLserializer for my class.
wrote a simple writeXML method for my class and it works.
My class has int members.
However, when I add a member of type datetime, the writeXML doesn't work anymore!
This is the sort of an error i get:
System.InvalidOperationException: There was an error reflecting property 'datetime member'. ---> System.InvalidOperationException: You need to add XmlChoiceIdentifierAttribute to the 'datetime member' member.
here is my code for writeXML:
public void WriteXml(String filePath)
{
StreamWriter stWriter = null;
XmlSerializer xmlSerializer;
xmlSerializer = new XmlSerializer(this.GetType());
stWriter = new StreamWriter(filePath);
System.Xml.Serialization.XmlSerializerNamespaces xs = new XmlSerializerNamespaces();
//To remove namespace and any other inline information tag
xs.Add("", "");
xmlSerializer.Serialize(stWriter, this, xs);
}
here are the attributes i have mentioned for the datetime member of the class:
[System.Xml.Serialization.XmlElementAttribute()]
[XmlElementAttribute(DataType = "date")]
note added: I get similar error for class member of type BOOL
any help would be greatly appreciated.
(I use framework 2, visual studio .net 2005, C#)