471,344 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,344 software developers and data experts.

SQL Session State Deserialization ?

WJ
I have problem in using "Deserialization" method to work with SQL Session
State. The session state data was recorded properly to MS/SQL Server
ASPState by a web application. I then attempted to read the session data
back from the SQL server using DataSet. Then call "Deserialize" to reveal
the session class. I got the following error:

"BinaryFormatter Version incompatibility. Expected Version 1.0. Received
Version 623915045.807743536."

Below is the code snippet:

======================
using System; //Sesison Class

namespace wSS
{
[Serializable()]
public class cSS
{
public string FirstName="";
public string LastName="";
public DateTime DOB;

public cSS()
{
}
}
}
=======================

...some codes here to read ASPState data into DataSet called myDS

byte[]b1=new byte[0]; //slot to hold raw data in ms/sql varbinary format
byte[]b2=new byte[0]; //slot to hold raw data in Text (string) format

b1=(byte[])myDS.Tables[0].Rows[0]["SessionItemShort"];
string s=Server.UrlEncode(Encoding.ASCII.GetString(b1));

b2=Encoding.ASCII.GetBytes(s);

//This displayed the correct content of the session class
TextBoxTraceLog.Text+="Check Point#7 - mySQLss="+s+
Environment.NewLine+Environment.NewLine;

MemoryStream ms=new MemoryStream(b2);

BinaryFormatter bf=new BinaryFormatter();
cSS cs=null; //see session class record above

try
{
cs=(cSS)bf.Deserialize(ms); //Here is the bomb
}
catch(Exception be)
{
TextBoxTraceLog.Text+="Check Point#8 - ERROR. Yep,"+
"it is goofed right here-> "+be.Message;

ms.Close();
return;
}

ms.Close();
**********************

PS: If you wish to see the complete sample program, please reply to this
message so that I can attach a 13KB zip file for you to look at.

Thanks for your help,

John

Jul 22 '05 #1
2 3400
Have you found a fix for this?

Aug 3 '05 #2
WJ
No Randy. I donot think it is possible. Only the application that builds the
SS would be compatible and able to reveal the class.

John

<ra********@fnf.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Have you found a fix for this?

Aug 14 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Jim Douglas | last post: by
2 posts views Thread by genc_ymeri | last post: by
8 posts views Thread by karahan celikel | last post: by
13 posts views Thread by Leszek Taratuta | last post: by
4 posts views Thread by tshad | last post: by
1 post views Thread by Seetha J | last post: by
reply views Thread by Ronak mishra | last post: by

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.