W
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
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