I have implemented SQL Server session state in my application however I am
having some problems. Simple objects stored in Session state are fine and are
handled by .NET, however when I try to store more complex objects such as an
ArrayList in session state I am not able to figure out exactly what I have to
do to serialize and deserialize the object.
There doesn't seem to be any code examples around when it comes to
serializing session objects. Could anyone provide me with some code that
would help?
I have managed to successfully serialize and deserialize an object to a file
but I am specifically looking to serialize the object to session state.
Thanks,
GaryAny class stored in session must implement the ISerializable attribute.
http://msdn.microsoft.com/library/d...lasst opic.asp
--
Robbe Morris - 2004/2005 Microsoft MVP C#
Earn money answering .NET Framework
messageboard posts at EggHeadCafe.com.
http://www.eggheadcafe.com/forums/merit.asp
"Gary" <Gary@.discussions.microsoft.com> wrote in message
news:1D664DFE-09DE-46BC-8703-46E108DCCA2B@.microsoft.com...
> Hello,
> I have implemented SQL Server session state in my application however I am
> having some problems. Simple objects stored in Session state are fine and
> are
> handled by .NET, however when I try to store more complex objects such as
> an
> ArrayList in session state I am not able to figure out exactly what I have
> to
> do to serialize and deserialize the object.
> There doesn't seem to be any code examples around when it comes to
> serializing session objects. Could anyone provide me with some code that
> would help?
> I have managed to successfully serialize and deserialize an object to a
> file
> but I am specifically looking to serialize the object to session state.
> Thanks,
> Gary
Gary,
All you have to do is to put a line
[Serializable]
before definition of every class you are going to save in the session state.
Eliyahu
"Gary" <Gary@.discussions.microsoft.com> wrote in message
news:1D664DFE-09DE-46BC-8703-46E108DCCA2B@.microsoft.com...
> Hello,
> I have implemented SQL Server session state in my application however I am
> having some problems. Simple objects stored in Session state are fine and
are
> handled by .NET, however when I try to store more complex objects such as
an
> ArrayList in session state I am not able to figure out exactly what I have
to
> do to serialize and deserialize the object.
> There doesn't seem to be any code examples around when it comes to
> serializing session objects. Could anyone provide me with some code that
> would help?
> I have managed to successfully serialize and deserialize an object to a
file
> but I am specifically looking to serialize the object to session state.
> Thanks,
> Gary
Hello,
Thank you very much for your reply, adding the <Serializable()> attribute to
my class has resolved my problem. I actually thought that you had to manually
serialize the object and then put it in to the session object, I had no idea
that .NET handles this for you as long as the serialization attribute is
added. I have spent the best part of my day trying to figure this out so
thanks very much!
Regards,
Gary
"Eliyahu Goldin" wrote:
> Gary,
> All you have to do is to put a line
> [Serializable]
> before definition of every class you are going to save in the session state.
>
> Eliyahu
> "Gary" <Gary@.discussions.microsoft.com> wrote in message
> news:1D664DFE-09DE-46BC-8703-46E108DCCA2B@.microsoft.com...
> > Hello,
> > I have implemented SQL Server session state in my application however I am
> > having some problems. Simple objects stored in Session state are fine and
> are
> > handled by .NET, however when I try to store more complex objects such as
> an
> > ArrayList in session state I am not able to figure out exactly what I have
> to
> > do to serialize and deserialize the object.
> > There doesn't seem to be any code examples around when it comes to
> > serializing session objects. Could anyone provide me with some code that
> > would help?
> > I have managed to successfully serialize and deserialize an object to a
> file
> > but I am specifically looking to serialize the object to session state.
> > Thanks,
> > Gary
>
Hello,
Thank you very much for your reply, adding the <Serializable()> attribute to
my class has resolved my problem. I actually thought that you had to manually
serialize the object and then put it in to the session object, I had no idea
that .NET handles this for you as long as the serialization attribute is
added. I have spent the best part of my day trying to figure this out so
thanks very much!
Regards,
Gary
"Robbe Morris [C# MVP]" wrote:
> Any class stored in session must implement the ISerializable attribute.
> http://msdn.microsoft.com/library/d...lasst opic.asp
> --
> Robbe Morris - 2004/2005 Microsoft MVP C#
> Earn money answering .NET Framework
> messageboard posts at EggHeadCafe.com.
> http://www.eggheadcafe.com/forums/merit.asp
>
> "Gary" <Gary@.discussions.microsoft.com> wrote in message
> news:1D664DFE-09DE-46BC-8703-46E108DCCA2B@.microsoft.com...
> > Hello,
> > I have implemented SQL Server session state in my application however I am
> > having some problems. Simple objects stored in Session state are fine and
> > are
> > handled by .NET, however when I try to store more complex objects such as
> > an
> > ArrayList in session state I am not able to figure out exactly what I have
> > to
> > do to serialize and deserialize the object.
> > There doesn't seem to be any code examples around when it comes to
> > serializing session objects. Could anyone provide me with some code that
> > would help?
> > I have managed to successfully serialize and deserialize an object to a
> > file
> > but I am specifically looking to serialize the object to session state.
> > Thanks,
> > Gary
>
0 comments:
Post a Comment