Can anyone explain to me what is a Serializable class and what is the significance of Serialization? Please try to be as clear as possible as I'am new to VB.NET.
Printable View
Can anyone explain to me what is a Serializable class and what is the significance of Serialization? Please try to be as clear as possible as I'am new to VB.NET.
For a class to be serializable means that it can be turned into a self describing XML (or binary XML) format.
The advantage of this is that you can serialize a class, store it (say in a database) and some time later pull it out and de-serialize it and you'll get back the exact same object you had before... even if the application which deserializes the class doesn't know the structure of the class.
Does that help you?
Thanx very much for the valuable information!
Ok that sounds good, but why would I want anything to be serializable and what makes a class serializable ( I mean what does this class has special beside keywords ). In other words, I don't see what's the point of this.
One big reason is so you can send it thru a wire to another app.
I just used this in a program I am improving on for a company in Nova Scotia.
They use this to create "profiles" of information, which is held in a class to be used in another program.
We serialize the class to a file, then load that same class when using the actual program.
Very good way of storing and then moving class information.
- josh
Ok I understand.. but what's the difference between serialize in XML and just write the class in a Binary file ?
Seems to me like both application needs the class definition anyway. So what's the difference ?
It's the same thing, just a different format.
Imports System.Runtime.Serialization.Formatters.Binary
vs.
Imports System.Runtime.Serialization.Formatters.Soap
ok so it's just a fancy way of doing things that used to be in place for a long time. So mainly it's another Bell and whistle thing.
I can tell you that using XML is pretty convenient.
I am not sure if this is true of most other storage practices, but you can open the XML file with notepad, and see every piece of data, and it's value, which made debugging and understanding this program much easier than it could have been.
- Josh
It can be interesting, but also, it's another way to expose your code. Though decompiling assemblies is quite simple if you don't obfuscate it.
:) It is not just bell and whistle thing, XML serialization is required for transmistting data for WEBSERVICE.Quote:
Originally Posted by Boumxyz2
So you serialize your object based on who you want to transmit it to. For example, sending the data to a webservice, you'd use XML but use binary if the endpoint is a .NET remoting service.