Powered by Blogger.

Sunday, February 23, 2014

Serialization and Deserialization in Remoting in C#.Net



In this post we will discuss about Serialization and Deserialization in C#.Net in Remoting. Also you can check out my previous posts on:

- How to get distinct data from tables in sql server 2008?

- Different ways to encrypt or decrypt password in asp.net

- ValidationSummary in asp.net

Serialization and Deserilization basically used in Distributed Applications like Remoting, Webservice, WCF etc. These are explained below.

Serialization and Deserilization:
-> To exchnge the information between both the parties i.e,client and server they use the process Serialization and Deserialization.

-> An application represents the data in high level (object format) which can't flow freely,it needs to convert into low level(binary or text) and then it transferred to other system where on the target machine low level data has to be converted back into high level.

-> Serilization is a process of converting high level data to low level data and De-serialization is the the process of converting low level data to high level data.

-> If the client and sever in one OS,it is Binary format and if they are in differnet OS, it is Text format.

-> Remoting provides Formatter Classes to perform Serilization and Deserialization.

These are as follows:
1. Soap Formatters: HttpServerChannel,HttpClientChannel
Soap Fomatters are used for text serialization and deserialization and Binary Formatters are used for binary serialization and deserialization.

2. Binary Formatters:TCPServerChannel,TCPClientChannel
Binary is more efficient (time and memory used) and not human readable.Soap is human readable.

We can serialize our own classes if we mark them as [Serializable] attribute that means it  serializes all members of a class, except those marked as [NonSerialized].