Introducing Serialization in .NET
page 12 of 14
by Joydip Kanjilal
Average Rating: 
Views (Total / Last 10 Days): 73309/ 78

Points to remember

This section deals with some of the points that we have already covered in this article and some others that we have not, but are still very important and relate to the serialization and de-serialization concepts of .NET.

When you apply the Serializable custom attribute to a type, all instance fields of the class (public, private, protected, etc.) are serialized automatically.

XmlSerializer does not use the ISerializable interface; rather, it uses the IXmlSerializable interface.  The XmlSerializer class can only serialize the public properties of the class, whereas the BinaryFormatter class can serialize private fields using the ISerializable interface.

The Serializable attribute is a must for making a class serializable irrespective of whether we have implemented the ISerializable interface in this class.  When we serialize a class, the objects of the references to other classes that are contained in this class are also serialized if they are marked as serializable.  All members are serialized, including public, private or protected members. Furthermore, even circular references are supported by binary serialization.  Note that read only properties are not serialized except the collection class objects.  However, the read only properties can be serialized using binary serialization.

If we do not require serializing a particular property of a class when using an XmlSerializer, we have to mark the property with the custom attribute XmlIgnoreAttribute.  When using a SoapFormatter we have to use the SoapIgnoreAttribute instead.  The XmlSerializer generates an in-memory assembly optimized for each type since the initial invocation to a Web Service always takes so much time.  To combat this, we can use the sgen.exe tool to pre-generate the serialization assembly.

View Entire Article

User Comments

Title: Really Very Good, and easy to understand Article   
Name: Ved Prakash
Date: 2006-12-29 6:24:11 AM
Really Very Good, and easy to understand Article
Date: 2006-12-27 7:30:09 AM
Title: Good Article   
Name: santosh
Date: 2006-12-08 1:50:03 AM
Very nice one for those who doen't have much idea about serilazation. Basiaclly it is giving fair introduction.
Title: Good. Need Help   
Name: Nandhini.S
Date: 2006-11-10 6:21:53 AM
This is very good for the starters to begin serialization. But im having doubt in Hoe to store a comple Windows ,Form object in XML document to reconstruct later.
Title: Fabulous! Good job   
Name: Mohammed Abrar
Date: 2006-11-07 2:07:16 AM
This is a fantastic article about Serialization.
Special thanks to the author Joydip Kanjilal
Title: Excellent!   
Name: Peter Royle
Date: 2006-10-17 5:51:07 AM
The best article I've seen for someone who knows nothing about serialisation (sic).
Title: Great Yaar   
Name: Rangarajan
Date: 2006-10-11 7:28:52 AM
Great explanation.. Simple and subtle, understandable and staright forward..
Title: Thank you for your contribution!   
Name: Mamiow
Date: 2006-10-11 12:30:50 AM
Very good and understanding article.
Title: best of one   
Name: Mukesh
Date: 2006-10-09 11:24:54 AM
Very nice article....

Title: What about Performance   
Name: Satyadev Singh
Date: 2006-10-09 3:22:28 AM
Hi, This is really a excellent article, however I have some concern regarding the CPU performance when we are going to use SOAP formatter, because in my previous project I used Binary formatter and got CPU uses increased.
That's why I am scared about the CPU performance because in that particuler apps will have 1 hit per second.

You can reach me at singhsatyadev[*at*]gmail[#dot#]com

Title: Nice Article   
Name: ArunKumar P
Date: 2006-10-09 3:02:15 AM
It is useful for Beginner's
Title: GIS Architect   
Name: Naren Ranganathan
Date: 2006-10-07 6:48:58 PM
Great article on Serialization for newbies.
Title: Diff bet SOAP Formatter & Binary Formatter & XML Formatter   
Name: Jitendra C
Date: 2006-10-03 7:27:51 AM
Great!It gives a broad picture of Serialization.I wanted to know more on Difference between SOAP Formatter & Binary Formatter & XML Formatter
Title: need details   
Name: Haroon
Date: 2006-09-29 1:46:27 AM
this article is good. but what if we want to know that which .net types (e.g SQL types for .net like SQLBoolean and e.t.c.., that are not serializable) are serializable.
I would appreciate if you can provide list of the types that are not serializable in .net
Title: Good for starters   
Name: Sandeep Gulati
Date: 2006-09-25 1:55:25 PM
A good articles for starters.
Title: gr8 article   
Name: abhi_viking
Date: 2006-09-25 7:29:02 AM
really useful 1
Title: Very useful   
Name: BT
Date: 2006-09-23 11:29:27 PM
Very nice article but I'm still left to wonder which of the serilization methods described above is the best one to use (most widely used in the field).
Title: Simple but most Effective   
Name: Mazher Yasin
Date: 2006-09-21 2:15:44 AM
Greate Effort
Title: Superb   
Name: Amin
Date: 2006-09-13 2:58:59 PM
10 out of 10
Title: Very Good Introduction   
Name: Bharat Sisodiya
Date: 2006-09-12 8:20:29 AM
Very good Information for Starters
Title: Great Article   
Name: Michelle
Date: 2006-09-06 3:53:20 PM
Great article - good information!

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024  |  Page Processed at 2024-04-18 3:13:11 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search