473,395 Members | 1,742 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,395 software developers and data experts.

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

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...;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

Feb 16 '06 #1
2 1416
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)

"Evian Spring" <ev**********@canada.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
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...;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

Feb 16 '06 #2
Thanks it makes sense. When you "some internal values" for Class1 in
my example, you mean the private members of class1?

Feb 16 '06 #3

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

Similar topics

2
by: Utada P.W. SIU | last post by:
i have write a class in asp class employee public employeeId public teamid public name private sub class_initialize() end sub
11
by: Stephanie Stowe | last post by:
Hi. I have an ASP page which stores a cookie. That cookie is then read on a different server. This is the crux of an ASP / JSP bridge I am creating for allowing a user to seemlessly switch from an...
11
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate...
5
by: Abhilash.k.m | last post by:
This is regarding the session management using Out of proc session management(SQL SERVER). Among the samples below which one is better to set the session? 1. There are 20 session...
2
by: John A Grandy | last post by:
for high traffic public websites , what are the proven options for session-state storage & management ? is an out-of-process state-server generally preferred over a sql-server ? what are the...
6
by: Angel | last post by:
I am trying to save private information such as user id and password from one application and send it to another application. I tried saving the information in the Session Object and when the user...
2
by: Chris Puncher | last post by:
Hi. I have a RCW class that was generated by the VS.NET2003 IDE when I added a COM dll reference to my project. This all works fine when I call methods on it. My initial problem is that in...
6
by: Extremest | last post by:
I am new to threading and trying to figure some things out. Are all variables in a thread set to only that thread? Meaning if I create 2 instances of a class and then put each one in a different...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.