Store and Recover Information About Object Using Binary Serialization in C#

Report Place-of-business and Recover Notice environing Aim Using Binary Serialization in C# What is Binary Serialization: Serialization is the process insertion an aim and converting it to a format which can be transported through net production or place-of-business into a storage moderation, the storage moderation could be polish, database, or remembrance. The . NET Frameproduction provides two indications of serialization, XML serialization and Binary serialization. There are too three formats granted by the Microsoft . NET frameproduction to which aims can be serialized. The formats are binary, SOAP, and XML. Binary serialization can either the binary or the SOAP formatter, are harmonious for storing aim Notice in . NET applications, and you don’t demand distribute the notice delay non-. NET programs. When I observation Binary serialization adown I moderation “Binary serialization” using binary formatter, as defective look. Why use Binary Serialization: The binary serialization productioning chart is: [pic] The chart too can bestow the other two format of serialization. so why we use Binary serialization instead of use the other two? What the usage and disusage of binary serialization? The binary serialization is the most conglomerate and easy of the three formats and it is the fastest one of the three formats. Too the binary serialization can serialize all the aver of the aim, including indication notice. Therefore when the aim is deserialized, you get an obsequious and easily administrative delineation of the primordial, which xml accomplish not It ignores retired constituent fields and properties. The ocean secretiveness of using binary serialization is that binary serialization depends on platform, conjuncture XML and SOAP do not unite to that secretiveness. Therefore barely when all your applications which use serialization are . net frameproduction applications, you can use binary serialization, incorrectly uses other two formats instead. Using Binary Serialization in C#: The command to using Binary serialize is very isolated. The plod is: 1) beget an exemplification of an BinaryFormatter rank (using the interface iForamatter) 2) ignoring it an aim and an unconcealed exit 3) iFormatter. Serialize regularitywrites the aim's aver to the exit. Adown I accomplish likeness a very isolated command to serialize an aim flatter aPerson to a polish. To perform a rank serializable we must indication it delay the serializable attainment at anteriorly the rank command The command is: [Serializable] open rank Person then we demand 2 namespaces for using serialization in our application: using System. Runtime. Serialization. Formatters. Binary; using System. Runtime. Serialization; then use the command adown to Serialize: //beget an exemplification of an BinaryFormatter rank(IFormatter is a interface) IFormatter formatter = new BinaryFormatter(); //beget a exit Exit exit = new FileStream("filename", FileMode. Create, FileAccess. Write, FileShare. None); //ignoring exit and aim to the exit formatter. Serialize regularity for doing Serialization formatter. Serialize(stream, aPerson); //finished delay the exit exit. Close(); The deserialize true as isolated as serialize, the command are: IFormatter formatter = new BinaryFormatter(); Exit exit = new FileStream("MyFile. dat", FileMode. Open, FileAccess. Read, FileShare. Read); Person clone = (Person) formatter. Deserialize(stream); exit. Close(); Some Important not for Serialization: ? the constructors are not flattered when an aim is deserialized. the Serializable attainment cannot be lineal. ? there are some Security issues of serialization you can mark The Security and Serialization (http://msdn. microsoft. com/library/? url=/library/en-us/cpguide/html/cpconsecurityserialization. asp)question in the Frameproduction Documentation exalt reading: This fame true explains the very basic conception of Binary serialization for exalt examine the forthcoming links accomplish succor. Serializing Objects: http://msdn. microsoft. com/library/default. asp? url=/library/en-us/cpguide/html/cpovrSerializingObjects. sp C# Aim Serialization by Budi Kurniawan http://www. ondotnet. com/pub/a/dotnet/2002/08/26/serialization. html References: Serializing Objects: http://msdn. microsoft. com/library/default. asp? url=/library/en-us/cpguide/html/cpovrSerializingObjects. asp http://www. c-sharpcorner. com/Language/serializingObjectsinCS. asp ----------------------- Deserialization Binary Serialization netproduction Deserialization Binary Serialization Delineation of Your Aim A File, Database or remembrance Storage moderation Another Application Your aim Your Application