Storing Session in Sql Server Serialization exception

Discussion in 'ASP .Net' started by jakk, Mar 7, 2005.

  1. jakk

    jakk Guest

    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)
    jakk, Mar 7, 2005
    #1
    1. Advertising

  2. jakk

    Marina Guest

    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.

    "jakk" <> wrote in message
    news:...
    > 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)
    >
    Marina, Mar 7, 2005
    #2
    1. Advertising

  3. jakk

    jakk Guest

    Thanks for the reply....I have started storing custom DataTable in
    Session now that derives from ISerializable interface and implements
    it.
    jakk, Mar 8, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jakk
    Replies:
    2
    Views:
    769
  2. =?Utf-8?B?QWJoaWplZXQgS3VtYXI=?=

    Storing Session in SQL Server

    =?Utf-8?B?QWJoaWplZXQgS3VtYXI=?=, Feb 7, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    354
    Marina Levit [MVP]
    Feb 7, 2006
  3. Replies:
    8
    Views:
    2,225
    deadsea
    Jan 2, 2005
  4. Replies:
    3
    Views:
    1,009
  5. Dimitri Ognibene
    Replies:
    4
    Views:
    764
    Dimitri Ognibene
    Sep 2, 2006
Loading...

Share This Page