473,320 Members | 1,580 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Serializable, what and why?

Could someone help me understand 'Serializable'?

What is this 'Serializable' why do we need it and how do we use it? Any
link or simple example would be great.

May 1 '06 #1
6 3263
DBC User,

Serialization is the act of being able to take an instance of an object
and save it in its current state to another storage medium. In .NET, this
is always a stream, but since streams can have different backings, the uses
for this mechanism are virtually limitless.

One use is in remoting situations. When you pass parameters to/from a
method that is being executed in an app domain outside of your own,
serialization is used to package the parameters into byte streams that can
be passed to the other app domain.

You can also save the stream to a file on disk, or in a database, and
then deserialize the instance later, continuing to use it.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"DBC User" <db*****@gmail.com> wrote in message
news:11*********************@g10g2000cwb.googlegro ups.com...
Could someone help me understand 'Serializable'?

What is this 'Serializable' why do we need it and how do we use it? Any
link or simple example would be great.

May 1 '06 #2
http://msdn.microsoft.com/msdnmag/issues/02/04/net/ is probably a good
introduction.

Cheers,

Greg
"DBC User" <db*****@gmail.com> wrote in message
news:11*********************@g10g2000cwb.googlegro ups.com...
Could someone help me understand 'Serializable'?

What is this 'Serializable' why do we need it and how do we use it? Any
link or simple example would be great.

May 1 '06 #3
Serialization just means to store an object as a byte stream. It will
typically be an XML text byte stream, or a binary byte stream. You need
this functionality to store an object in a file, or to send it over a
wire. An object that is "serializable" meets the criteria for being
serialized automatically into XML (typically meaning it has public
read/write properties, at least one empty constructor overload, and
perhaps a few others). In order to be serialized as XML you will lose
the methods, of course. XML serialization is typically used for data
container classes and collections. Binary serialization can preserve
the methods and private members, but people normally don't speak in
terms of binary serialization.

May 1 '06 #4
Thanks a bunch guys. Greg, the link is very good.

May 1 '06 #5
Eric,

See inline:
Serialization just means to store an object as a byte stream. It will
typically be an XML text byte stream, or a binary byte stream.
A byte stream is a byte stream, there isn't a different flavor to either
of them. How they are interpreted is a different thing. The SOAP formatter
serializes instances into SOAP messages, which ultimately can be stored as a
byte stream, while the binary formatter uses a much more compact
representation.
You need this functionality to store an object in a file, or to send it
over a
wire. An object that is "serializable" meets the criteria for being
serialized automatically into XML (typically meaning it has public
read/write properties, at least one empty constructor overload, and
perhaps a few others).
It is eligible to be serialized using the SOAP formatter (which produces
XML), but it does not automatically mean that you can use XML serialization.
In order to be serialized as XML you will lose the methods, of course.
XML serialization is typically used for data container classes and
collections.
Binary serialization can preserve
the methods and private members, but people normally don't speak in
terms of binary serialization.


This isn't true. When you serialize an instance of a type, the method
information is not stored. That is a part of the type itself, and there is
no reason to store it. Rather, just the field values are stored. Storing
the method information would mean you are storing code in some way, or local
variables, and that's not what happens. It would make no sense to do so.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
May 1 '06 #6
When I was talking about binary serialization I was thinking of Marshal
By Value in remoting, in which a complete object (including methods) is
serialized and sent over the wire. I guess this isn't a generalized
case of using a Binary Formatter. I not exactly sure how this is done -
I haven't used it myself.

May 3 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Magnus Byne | last post by:
Hi, I have a problem using serializable transactions. In one transaction I select a single specific row from a table using a where clause (this causes it to acquire and hold a range lock). In...
0
by: xmail123 | last post by:
Hi, Hi, As was pointed out whatever you return from a WebMethod needs to be serializable to SOAP. An ArrayList is not serializable. I will be needing to return other data types from web...
8
by: xmail123 | last post by:
Hi, As was pointed out whatever you return from a WebMethod needs to be serializable to SOAP. An ArrayList is not serializable. I will be needing to return other data types from web methods. ...
5
by: Ben Terry | last post by:
I get the following compilation error: "The type or namespace name 'Serializable' could not be found (are you missing a using directive or an assembly reference?)" Can anyone tell me why the...
0
by: Poewood | last post by:
I am experimenting with saving files in binary format on the Pocket PC. When I use the attribute I get error in Compact Framework. Do i have to use the attribute to make a class serializable? ...
2
by: John | last post by:
Hi What is a Serializable class compared to a normal class? Thanks Regards
9
by: Developer | last post by:
Hi, How can one tell wsdl.exe/VS.NET web service proxy generatioon to to put on imported classes? For example, i fin your web service you use a class: class Data { }
1
by: cpnet | last post by:
I have a DataTable defined in a strongly-typed DataSet: public class MyDataSet: DataSet... { ... public class MyDataTable: DataTable... { ...}
3
by: Techno_Dex | last post by:
I'm wanting to create a Wrapper (or Extender depending on how you look at it) for a Serializable object that I then want to send over a webservice. Basically I want to create a Serializable Object,...
8
by: Techno_Dex | last post by:
Has anyone come up with a slick way to make Custom Serializable Objects to behave like DataSets when using WebServices? What I'm looking for is some way to force the WSDL generated code to create...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.