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

Report Store and Recover Information about Object Using Binary Serialization in C# What is Binary Serialization: Serialization is the process taking an object and converting it to a format which can be transported through net work or store into a storage medium, the storage medium could be file, database, or memory. The . NET Framework provides two types of serialization, XML serialization and Binary serialization. There are also three formats provided by the Microsoft . NET framework to which objects can be serialized. The formats are binary, SOAP, and XML.
Binary serialization can either the binary or the SOAP formatter, are suitable for storing object Information in . NET applications, and you don’t need share the information with non-. NET programs. When I mention Binary serialization below I mean “Binary serialization” using binary formatter, as short expression. Why use Binary Serialization: The binary serialization working chart is: [pic] The chart also can present the other two format of serialization. so why we use Binary serialization instead of use the other two? What the advantage and disadvantage of binary serialization?
The binary serialization is the most compact and light of the three formats and it is the fastest one of the three formats. Also the binary serialization can serialize all the state of the object, including type information. Therefore when the object is deserialized, you get an accurate and fully functional copy of the original, which xml will not It ignores private member fields and properties. The main limitation of using binary serialization is that binary serialization depends on platform, while XML and SOAP do not adhere to that limitation.

Therefore only when all your applications which use serialization are . net framework applications, you can use binary serialization, otherwise uses other two formats instead. Using Binary Serialization in C#: The code to using Binary serialize is very simple. The step is: 1) create an instance of an BinaryFormatter class (using the interface iForamatter) 2) pass it an object and an open stream 3) iFormatter. Serialize methodwrites the object’s state to the stream. Below I will show a very simple code to serialize an object call aPerson to a file.
To make a class serializable we must mark it with the serializable attribute at before the class code The code is: [Serializable] public class Person then we need 2 namespaces for using serialization in our application: using System. Runtime. Serialization. Formatters. Binary; using System. Runtime. Serialization; then use the code below to Serialize: //create an instance of an BinaryFormatter class(IFormatter is a interface) IFormatter formatter = new BinaryFormatter(); //create a stream Stream stream = new FileStream(“filename”, FileMode. Create, FileAccess.
Write, FileShare. None); //pass stream and object to the stream formatter. Serialize method for doing Serialization formatter. Serialize(stream, aPerson); //finished close the stream stream. Close(); The deserialize just as simple as serialize, the code are: IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(“MyFile. dat”, FileMode. Open, FileAccess. Read, FileShare. Read); Person clone = (Person) formatter. Deserialize(stream); stream. Close(); Some Important not for Serialization: ? the constructors are not called when an object is deserialized. the Serializable attribute cannot be inherited. ? there are some Security issues of serialization you can visit The Security and Serialization (http://msdn. microsoft. com/library/? url=/library/en-us/cpguide/html/cpconsecurityserialization. asp)topic in the Framework Documentation further reading: This report just explains the very basic idea of Binary serialization for further study the following links will help. Serializing Objects: http://msdn. microsoft. com/library/default. asp? url=/library/en-us/cpguide/html/cpovrSerializingObjects. sp C# Object 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 network Deserialization Binary Serialization Copy of Your Object A File, Database or memory Storage medium Another Application Your object Your Application

Don't use plagiarized sources. Get Your Custom Essay on
Store and Recover Information About Object Using Binary Serialization in C#
Just from $13/Page
Order Essay
Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more

Order your essay today and save 20% with the discount code WELCOME