How do you define a NonSerialized field with public XML serialization accessories?
[NonSerialized] public String _fooBar; //Declaring the property here will serialize the _fooBar field public String FooBar { get { return _fooBar; } set { _fooBar = value; } }
Properties are not serialized by BinaryFormatter , but only fields. The [NonSerialized] attribute does not make sense for XML serialization. Use [XmlIgnore] .
BinaryFormatter
[NonSerialized]
[XmlIgnore]