I am bit

I created a class and tried to save in ViewState, I got an error asking to
mark class with searizable attribute. But I was able to save that class in
Application and Session without marking.
How this Serialization workes and for which type of .NET framework classes?
Thanks,Basically serialization means the class has the ablility to convert =
itself into a string of characters, and also be able to take this string =
of characters and make a new instance of itself. For your own class, =
you would have to create these methods in order to save it to the =
viewstate (viewstate is essentially, a string of characters!)
This certainly can get quite tricky, so unless you really want to =
persist this class in the viewstate, I'd just use the session.
"asp.net User" <asp.net User@.discussions.microsoft.com> wrote in message =
news:0F2DDEB3-1912-4C44-B884-85D629138106@.microsoft.com...
>=20
> Dear All,
>=20
> I am bit

>=20
> I created a class and tried to save in ViewState, I got an error =
asking to=20
> mark class with searizable attribute. But I was able to save that =
class in =20
> Application and Session without marking.
>=20
> How this Serialization workes and for which type of .NET framework =
classes?
>=20
> Thanks,
>=20
>=20
>=20
>=20
>
When you store your object in the Session or the Application I'm guessing
that you're storing a reference to your existing in-memory object. Although
if you're using a sessionState mode were StateServer or SQLServer this
certainly would not be the case.
When you store your object in the ViewState, your object makes a trip to the
client in a hidden field and thus needs to be serializable.
"asp.net User" wrote:
> Dear All,
> I am bit

> I created a class and tried to save in ViewState, I got an error asking to
> mark class with searizable attribute. But I was able to save that class in
> Application and Session without marking.
> How this Serialization workes and for which type of .NET framework classes
?
> Thanks,
>
>
>
Thanks Raterus,
I would like to know why Serialization attribute is not requaired in case of
Session and Application.
Thanks Brad ,
I am using "InProc" sessionState.
>I'm guessing
> that you're storing a reference to your existing in-memory object.
Hmm.. not getting this point.
I *think* even in this case(Session and Application) automatic
XMLSerialization of object happens and that Serialized object would be
stored.
Is this correct?
"Brad Quinn" wrote:
> When you store your object in the Session or the Application I'm guessing
> that you're storing a reference to your existing in-memory object. Althou
gh
> if you're using a sessionState mode were StateServer or SQLServer this
> certainly would not be the case.
> When you store your object in the ViewState, your object makes a trip to t
he
> client in a hidden field and thus needs to be serializable.
> "asp.net User" wrote:
>
It's really not tricky at all. To make your class serializable you add an
attribute.
[Serializable]
public class MyClass
{
}
To store an instance of MyClass in the ViewState you do something like this;
MyClass someInstance = MethodReturningMyClass();
ViewState["originalValue"] = someInstance;
And to get it out again;
MyClass originalInstance = (MyClass)ViewState["originalValue"];
"Raterus" wrote:
> Basically serialization means the class has the ablility to convert itself into a
string of characters, and also be able to take this string of characters and make a
new instance of itself. For your own class, you would have to create these methods
in
order to save it to the viewstate (viewstate is essentially, a string of characters!)[color
=darkred]
> This certainly can get quite tricky, so unless you really want to persist
this class in the viewstate, I'd just use the session.
> "asp.net User" <asp.net User@.discussions.microsoft.com> wrote in message n
ews:0F2DDEB3-1912-4C44-B884-85D629138106@.microsoft.com...
>[/color]
Application never uses serialization as it just a reference to the object.
InProc sessions also just are a reference and do not use serialization. Any
out of proc session manager will use serialization.
-- bruce (sqlwork.com)
"asp.net User" <aspnetUser@.discussions.microsoft.com> wrote in message
news:C46ECA6E-60D4-48B3-A5CC-53B8FB4929E6@.microsoft.com...
> Thanks Brad ,
> I am using "InProc" sessionState.
>
> Hmm.. not getting this point.
> I *think* even in this case(Session and Application) automatic
> XMLSerialization of object happens and that Serialized object would be
> stored.
> Is this correct?
>
>
> "Brad Quinn" wrote:
>
guessing
Although
the
asking to
class in
classes?
0 comments:
Post a Comment