Suppose let say we have a UDT(User Defined Type) object called person which has the following property's Name,Phone and SSN. Here SSN is read-only properties. When you serializing this person object you get the following error.because XmlSerializer wont serialize the Private members.
To serialize the person object we can implement the IXmlSerializable Interface as shown below..
Now if you try serialize it will be serialized as XML with out error.
Here is the result