SQL Server Session Management Mode in .NET
page 4 of 8
by Sandeep Acharya
Feedback
Average Rating: 
Views (Total / Last 10 Days): 34133/ 63

Serialization

So far we have learned that SQL Server stores sessions exploiting the process of Serialization. Now, let us dig a bit more into it. Serialization is noting but the act of producing an item in the form of memory bytes.

For the process of serialization we need two things. One is a Formatter and another is a Stream Object.

The Serialize method of the Formatter object actually does everything that is required.

Let us see the code for this purpose. The class written below is the class whose object is going to be serialized. For that purpose, the <Serializable()> attribute are added.

Listing 1

<Serializable()> Public Class DataDescription
  Public Data As Integer
  Public Description As String
 
  Public Sub New(ByVal NewData As IntegerByVal NewDescription As String)
    Data = NewData
    Description = NewDescription
  End Sub
 
  Public Overrides Function ToString() As String
  Return Description
End Function
 
End Class

The code below shows the actual method of Serialization.

Listing 2

Public Function SerializeData( _
ByVal oDataToBeSerialized As ObjectAs System.IO.MemoryStream
  Dim oFormatter As New _
    System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()
  Dim oStream As New System.IO.MemoryStream()
  oFormatter.Serialize(oStream, oDataToBeSerialized)
  Return oStream
End Function

View Entire Article

User Comments

Title: SerializeData list arrays   
Name: Sachin Kulkarni
Date: 2009-05-18 5:05:50 AM
Comment:
Hi,
I read the article it is very good information. I have just one question does the SerializeData function Serialize the system.collection objects too. As you are using the .Net Serialize method.
If not how can I do it?

Thanks in advance,
sachin
Title: SQL Server Session Management Mode in .NET   
Name: Ravikumar Bhuvanagiri
Date: 2009-02-13 11:41:18 AM
Comment:
This Article is very usefull.






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-05-11 3:47:33 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search