Geeks With Blogs
Srijith Sarman Time,space and living

Serialization is one among those beutiful techniques, which every programmer would love to do.It reduces the complexity of an operation to  great extents. Windows forms uses serialization internally in the clipboard method ,which uses for copy and paste and uses the same for storing data in sessions.One major use of serialization comes when we need to pass object through the network. I am not digging into the details of Binaryformatter,Soapformatter or Xmlformatter available with .Net  framework ,as there are many resources available on these in the net.

 Serialization may seem as very easy,as we have already equipped with all the necessary formatters.Only thing that we need to do is ,to get a stream which derives from the abstract class System.Io.Stream, and write some code as shown below., We can return the resultant stream accordingly.

                            BinaryFormatter bi=new BinaryFormatter();
                            MemoryStream mem=new MemoryStream();

      Writing a custom formatter is a really challenging task for any programmer.As of now,I know only about Angelo scotto's compactFormatter which  has succeeded to a certain extent in emulating the  formating algorithms, and also  it's faster than .Net framework formatters.But it's still in beta..Net formatters converts all the object graphs into binary streams(Yeah! That's serialization).Eventhough microsoft has assured about the reliability of it's formatters,serializing complex datatypes such as datasets are indeed a headache .Despite of the type of formatters which is being used ,dataset would always converts in to xml. I think it's better to deal with this issue and solutions in a seperate post.

Even though binaryformatter fits for almost all the needs ,we may think that it can be still improved.for example if I serialize a string of length 60 the returned byte arry will have a length of  250.But if I use some other methods such as Encoding.Ascii.GetBytes() ,it returns only 60 bytes as the byte array.Ofcourse,there is difference in terms of functionality.

I am not continuing my blah ,blah .For references about serialization ,to me,the best resources are.

After reading all these article ,you would get a clear cut picture about serialization.

Posted on Wednesday, October 25, 2006 5:34 PM | Back to top

Comments on this post: Serialization in .Net

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Srijith Sarman | Powered by: