Storing Session in Sql Server Serialization exception

J

jakk

Below is the exception that Iam getting. It says that the DataView that
Iam storing in the session is not Serializable. BUt works fine if I
store in the inproc session and fails if I switch to storing the
session in Sql Server.

Please let me know if Iam doing anything wrong.


Unable to serialize the session state. Please note that
non-serializable objects or MarshalByRef objects are not permitted when
session state mode is 'StateServer' or 'SQLServer'

[SerializationException: The type System.Data.DataView in Assembly
System.Data, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089 is not marked as serializable.]

System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType
type, Boolean excludeNonSerializable) +868

System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type
type, StreamingContext context) +300

System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()
+103

System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object
obj, ISurrogateSelector surrogateSelector, StreamingContext context,
SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter)
+493

System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object
obj, ISurrogateSelector surrogateSelector, StreamingContext context,
SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter) +48

System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object
graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
+683

System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream
serializationStream, Object graph, Header[] headers, Boolean fCheck)
+136

System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream
serializationStream, Object graph) +13
System.Web.Util.AltSerialization.WriteValueToStream(Object value,
BinaryWriter writer)
 
M

Marina

Putting it into SQL Server means having to serialize it and put it in a
database table. Storing it in memory means having to do absolutely nothing.

So, anything you put in session when using SQL server session state has to
be serializable. DataView is not. So you can't store it in Session if using
this session state model.
 
J

jakk

Thanks for the reply....I have started storing custom DataTable in
Session now that derives from ISerializable interface and implements
it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top