Keith,
Yes I am using XmlAttribute and XmlElement attributes.
If a class implements IEnumerable however, you cannot add XML attributes to
it.
For example
[XmlType("Collection")]
public class joaCollection : joaItem, IEnumerable
{
//...
}
Results in the following error...
System.InvalidOperationException: There was an error reflecting type
'DotnetBench.joaCollection'. ---> System.InvalidOperationException: XML
attributes may not be specified for the type DotnetBench.joaCollection.
I also found a reference that says that this behavoir is "by design". Whose
idiotic design is this?
I am very unhappy about this. The reason I want to use IEnumerable is so my
collection can be used in foreach statements. However it appears that if I
want to have a few XML serialized properties in my class I will need to
abandon IEnumerable!
Thanks for the help,
Bob Rundle
"Keith Patrick" <ri*******************@nospamhotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Have you marked your properties with [XmlAttribute] and/or [XmlElement]?
Those are "hints" to the deserializer/serializer as to what/how do
convert. I wrote a custom deserializer that can handle abstract/concrete types and
had to use those attributes + write a few of my own extensively.
De/serialization can automatically handle some objects, but when you start
getting more complex objects, those attributes are indispensible.
"Bob Rundle" <ru****@rundle.com> wrote in message
news:eo****************@TK2MSFTNGP12.phx.gbl... I'm trying to serialize a class with XmlSerializer. This class
implements the IEnumerable interface. I implemented the IEnumerable interface for
reasons other than Xml serialization.
However I find that the XmlSerializer, because I have an IEnumerable
interface on this class, wants to ignore the public properties of this
class and simply serialize an array of objects.
I wand XmlSerializer to ignore the IEnumerable interface that I have
implemented on this class. How do I do that?
Regards,
Bob Rundle