Are all public read/write members serialized with XmlSerializer?

Posted by David on Stack Overflow See other posts from Stack Overflow or by David
Published on 2010-04-16T15:16:41Z Indexed on 2010/04/16 17:03 UTC
Read the original article Hit count: 275

Filed under:
|
|
|

I have a handful of public read/write members that are not being serialized and I can't figure out why. Reviewing some code, and my root class is marked serializable:

[Serializable]
public class MyClass

I have a default constructor that initializes 10-15 string members. There are about 50 public read/write string members in MyClass with get and set--no explicit serialization attributes are set on any of these. Serialization looks like this:

XmlSerializer x = new XmlSerializer(typeof(MyClass));
TextWriter twWriter = new StreamWriter(sFileName);
x.Serialize(twWriter, this);
twWriter.Close();

only a handful (20-30) of these members are actually seralized to my xml file. what am i missing or misunderstanding about the XmlSerializer class?

© Stack Overflow or respective owner

Related posts about Xml

Related posts about serialization