Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2006

Tip: Looking for answers? Try searching our database.

Question about SQL Session Management ASP.NET and How to serialise Object

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Evian Spring - 16 Feb 2006 00:36 GMT
We are planning on using "SqlServer" mode for our ASP.NET session
state.

I know for the classes we store in Session that I need to mark them
with the SerializableAttribute as described in this knowledge base
article:

http://support.microsoft.com/default.aspx?scid=KB;EN-US;q312112&ID=KB;EN-US;q312112

My question is, if I store in session a class that contains members
that are classes and so on, will marking my class with the
SerializableAttribute the only thing I need?

I have written a simple class shown below.....will marking
MyClassExample with SerializableAttribute the only thing I need?   I
think the member variable that are not object will serialize no problem
but I not sure for Class1 in my exmaple below...........I know I may
need to implement the ISerializable interface to control the
serialization process but I haven't found good examples on how to do
this yet.

   Public Class MyClassExample

       Private _MemberVariable_Of_Type_Integer As Integer
       Private _MemberVariable_Of_Type_String As String
       Private _MemberVariable_Of_Type_Class1 As Class1

       Public Property MemberVariable_Of_Type_Integer() As Integer
           Get
               Return _MemberVariable_Of_Type_Integer
           End Get
           Set(ByVal value As Integer)
               _MemberVariable_Of_Type_Integer = value
           End Set
       End Property

       Public Property MemberVariable_Of_Type_String() As String
           Get
               Return _MemberVariable_Of_Type_String
           End Get

           Set(ByVal value As String)
               _MemberVariable_Of_Type_String = value
           End Set
       End Property

       Public Property MemberVariable_Of_Type_Class1() As Class1
           Get

               Return _MemberVariable_Of_Type_Class1
           End Get

           Set(ByVal value As Class1)
               _MemberVariable_Of_Type_Class1 = value
           End Set
       End Property

       Public Sub New()
           Me.MemberVariable_Of_Type_Integer = -1
           Me.MemberVariable_Of_Type_String = ""
           Me.MemberVariable_Of_Type_Class1 = New Class1()
       End Sub

   End Class
Bruce Barker - 16 Feb 2006 01:29 GMT
maybe. in your example if class1 is serialiable, you are ok, else you will
fail.

if you mark a class Serializable, you are declaring the class can be
serialized. when serialization happens, each property is serialized using
reflection. if the datatype of the property supports serialization, you're
ok. if not, then serialization will fail.

if a class has a property whose datatype does not support ISerializable, or
some internal values need to be saved, then you need to implement
ISerializable.

for some classes there is no practical way to implement ISerializable, such
a DataReader,  or a SQLConnection,  or many classes that control unmanged
resources.

-- bruce (sqlwork.com)

> We are planning on using "SqlServer" mode for our ASP.NET session
> state.
[quoted text clipped - 60 lines]
>
>    End Class
Evian Spring - 16 Feb 2006 01:43 GMT
Thanks it makes sense.  When you "some internal values" for Class1 in
my example, you mean the private members of class1?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.