Serializable attribute is not related to XmlSerializer.

.Net has several methods of serialization and sometimes it causes a lot of confusion even for experienced programmers.
I believe the best article to describe the different methods is  Aaron Skonnard’s
Serialization in Windows Communication Foundation(MSDN Magazine > Issues > 2006 > August) (by some reason it’s not highly rated by Google and other articles are coming first for Serialization related requests)

There is also a brief comparison table in StackOverflow What are the differences between the XmlSerializer and BinaryFormatter.

I’ve recently read a good article XmlSerializer vs DataContractSerializer: Serialization in Wcf, but noticed that it is incorrectly describe SerializableAttribute.
[Serializable].is used by   System.Runtime.Serialization. (BinaryFormatter or obsolete SoapFormatter) and also by  DataContractSerializer/NetDataContractSerializer to be compatible with .Net Remoting.
However it is not used by XmlSerializer .XmlSerializer can operate on any public type without any special attributes.

 

Advertisements