473,839 Members | 1,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 SerializableAtt ribute 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
SerializableAtt ribute the only thing I need?
I have written a simple class shown below.....will marking
MyClassExample with SerializableAtt ribute 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_Intege r 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_Intege r
End Get
Set(ByVal value As Integer)
_MemberVariable _Of_Type_Intege r = 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.MemberVariab le_Of_Type_Inte ger = -1
Me.MemberVariab le_Of_Type_Stri ng = ""
Me.MemberVariab le_Of_Type_Clas s1 = New Class1()
End Sub
End Class

Feb 16 '06 #1
2 1439
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**********@c anada.com> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.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 SerializableAtt ribute 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
SerializableAtt ribute the only thing I need?
I have written a simple class shown below.....will marking
MyClassExample with SerializableAtt ribute 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_Intege r 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_Intege r
End Get
Set(ByVal value As Integer)
_MemberVariable _Of_Type_Intege r = 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.MemberVariab le_Of_Type_Inte ger = -1
Me.MemberVariab le_Of_Type_Stri ng = ""
Me.MemberVariab le_Of_Type_Clas s1 = 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
1573
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
2062
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 ASP service to a JSP service and have their session state returned to them. My question is, is there any way a hacker can spoof a cookie in a request? Thanks S
11
4277
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 threads of a multithreaded program using embedded SQL. Since the threads do not need to share transaction scopes, the sqleAttachToCtx family of APIs do not seem to be necessary. <quote> In the default implementation of threaded applications against...
5
2462
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 variables and all of them are being stored into session and accessed from session and individual session object. Example: Session = "XYZ", Session=100, Session="NAME", etc.
2
2197
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 relevant criteria ? is the primary criteria max expected total storage size (for all active sessions) versus max ram available on the state-server machine ? if ADO.NET objects (such as small DataTables) must be stored in session-state , is any...
6
256
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 goes to a from one application and then redirecting them to the different application it does get the information stored in the session object. Is there any way to store an information in one application and be able to access it to a different...
2
1609
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 ASP.NET I would like to add this to the Session object whilst using SQLServer as the session storage. Unfortunately, as this required the RCW class to be serializable, this won't work, and throws an exception saying you can't Serialize the Session...
6
5819
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 thread and run them will the local variables in functions be shared or will they be thread safe?
0
9854
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9696
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10903
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10584
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9425
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4482
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4063
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3131
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.