This is because XmlSerializer only serializes public fields/properties. Other forms of serialization can serialize private data, which constitutes a potential security risk, so you have to “opt in” using an attribute.
More Related Contents:
- XML Serialization and namespace prefixes
- Data Contract Serializer – How to omit the outer element of a collection
- Cloning objects without Serialization
- Using DataContractSerializer to serialize, but can’t deserialize back
- Proper way to implement IXmlSerializable?
- Serialize an object to XML
- How do you serialize a string as CDATA using XmlSerializer?
- Omitting all xsi and xsd namespaces when serializing an object in .NET?
- Serialize an object to string
- Can I make XmlSerializer ignore the namespace on deserialization?
- Deserializing into a List without a container element in XML
- How do you find out when you’ve been loaded via XML Serialization?
- How to decode string to XML string in C#
- When a class is inherited from List, XmlSerializer doesn’t serialize other attributes
- How can I make the xmlserializer only serialize plain xml?
- How to XML-serialize a dictionary
- Deciding on when to use XmlDocument vs XmlReader
- How can I serialize internal classes using XmlSerializer?
- How to write a comment to an XML file when using the XmlSerializer?
- Suppress Null Value Types from Being Emitted by XmlSerializer
- Checking if an object is a number in C#
- FileMode.Open and FileMode.OpenOrCreate difference when file exists? c# bug?
- Generating XML file using XSD file
- Cannot serialize member…. because it is an interface
- XmlSerializer Performance Issue when Specifying XmlRootAttribute
- Is there a reason why a base class decorated with XmlInclude would still throw a type unknown exception when serialized?
- How can I convert a DataTable to an XML file in C#?
- Is there a way to make DataContractSerializer output cleaner XML?
- C# Xml Serialization & Deserialization
- Prevent timezone conversion on deserialization of DateTime value