question about Serialization

B

Bjorn

Hi,

I read a lot of things about Serialization but i'm not sure i understand
what it is really doing.
Anyway, i use in my application the 'Profiles' which must contain things
like name of customers, address... and a kind of shoppinglist.
Therefore i created a class with "<Serializable()" and i created the
profiles in web.config and added "serializeAs="Binary", just like i read in
some doc. Everything works perfectly.

Now i removed "<Serializable()" from the class file and
"serializeAs="Binary" from web.config and it still works.

Could somebody explain me the difference between the two situations: with
"<Serializable()" and without "<Serializable()" ? What does that do and is
it recommended?

Thanks in advance
Bjorn


in App_Code:
<Serializable()> _
Public Class myClass
Private _name As string
.....
end class


in web.config:
<profile>
<properties>
...........
<add shoppinglist="eComm" serializeAs="Binary" .../>
</properties>
</profile>
 
P

Phill W.

Bjorn said:
I read a lot of things about Serialization but i'm not sure i understand
what it is really doing.

A Serializable object has code either in it or provided for it by the
Framework that allows it to be "written" out to and "read" back in from
an alternative, "portable" format (commonly Xml).

Typically, I use this to throw objects back and forth across the "Great
..Net Remoting Divide"; the client serializes an object to be passed,
hurls the serialized form across a socket connection to the server,
which dutifully "unpacks" it at the other end into [the same] object,
ready for use there.
Anyway, i use in my application the 'Profiles' which must contain things
like name of customers, address... and a kind of shoppinglist.
Therefore i created a class with "<Serializable()" and i created the
profiles in web.config and added "serializeAs="Binary", just like i read in
some doc. Everything works perfectly.

Does "everything" include any calls to [formatter].Serialize()?
Or putting an object into, say, the ASPNET Session object?

If you don't use the Serialization methods on the object then it doesn't
matter whether the object is Serializable or not.

HTH,
Phill W.
 
B

Bjorn

Hi thanks for helping..

The global.asax is empty (so no session object).
About "calls to [formatter].Serialize()", i have no such a thing ...
I suppose the object you mean to be serialised is the shoppinglist?
Can you give an example of code with c"alls to [formatter].Serialize()" and
where it should be placed? Or an example of in the session object?

And, i still don't understand the advantage of this (transforming data in
xml format) in the context of my application. Will it run faster?
Thanks



Phill W. said:
Bjorn said:
I read a lot of things about Serialization but i'm not sure i understand
what it is really doing.

A Serializable object has code either in it or provided for it by the
Framework that allows it to be "written" out to and "read" back in from an
alternative, "portable" format (commonly Xml).

Typically, I use this to throw objects back and forth across the "Great
.Net Remoting Divide"; the client serializes an object to be passed, hurls
the serialized form across a socket connection to the server, which
dutifully "unpacks" it at the other end into [the same] object, ready for
use there.
Anyway, i use in my application the 'Profiles' which must contain things
like name of customers, address... and a kind of shoppinglist.
Therefore i created a class with "<Serializable()" and i created the
profiles in web.config and added "serializeAs="Binary", just like i read
in
some doc. Everything works perfectly.

Does "everything" include any calls to [formatter].Serialize()?
Or putting an object into, say, the ASPNET Session object?

If you don't use the Serialization methods on the object then it doesn't
matter whether the object is Serializable or not.

HTH,
Phill W.
 
B

Bjorn

Does "serializeAs="Binary" in web.config not replacethe Serialization
method ?
In the whole project, i couldn't find any [formatter].Serialize().



Phill W. said:
Bjorn said:
I read a lot of things about Serialization but i'm not sure i understand
what it is really doing.

A Serializable object has code either in it or provided for it by the
Framework that allows it to be "written" out to and "read" back in from an
alternative, "portable" format (commonly Xml).

Typically, I use this to throw objects back and forth across the "Great
.Net Remoting Divide"; the client serializes an object to be passed, hurls
the serialized form across a socket connection to the server, which
dutifully "unpacks" it at the other end into [the same] object, ready for
use there.
Anyway, i use in my application the 'Profiles' which must contain things
like name of customers, address... and a kind of shoppinglist.
Therefore i created a class with "<Serializable()" and i created the
profiles in web.config and added "serializeAs="Binary", just like i read
in
some doc. Everything works perfectly.

Does "everything" include any calls to [formatter].Serialize()?
Or putting an object into, say, the ASPNET Session object?

If you don't use the Serialization methods on the object then it doesn't
matter whether the object is Serializable or not.

HTH,
Phill W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top