Session serialization error when sessionState mode is not "InProc"

Discussion in 'ASP .Net Web Services' started by feliz, Aug 29, 2008.

  1. feliz

    feliz Guest

    - Create a new webservice project with a webmethod that has enabled sessions
    (WebMethod(EnableSession=true) attribute).
    - Set the sessionState mode to any mode other than "InProc".
    - Run the project (either in IIS or the Development server)
    - Call the webmethod

    The request will fail with the following exception:

    Unable to serialize the session state. In 'StateServer' and 'SQLServer'
    mode, ASP.NET will serialize the session state objects, and as a result
    non-serializable objects or MarshalByRef objects are not permitted. The same
    restriction applies if similar serialization is done by the custom session
    state store in 'Custom' mode.


    Stack Trace:

    [SerializationException: Type 'System.Resources.RuntimeResourceSet' in
    Assembly 'mscorlib, Version=2.0.0.0, Culture=neutral,
    PublicKeyToken=b77a5c561934e089' is not marked as serializable.]

    System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type) +2700482

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

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

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

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

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

    System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck) +131
    System.Web.Util.AltSerialization.WriteValueToStream(Object value,
    BinaryWriter writer) +1513

    [HttpException (0x80004005): Unable to serialize the session state. In
    'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state
    objects, and as a result non-serializable objects or MarshalByRef objects are
    not permitted. The same restriction applies if similar serialization is done
    by the custom session state store in 'Custom' mode.]
    System.Web.Util.AltSerialization.WriteValueToStream(Object value,
    BinaryWriter writer) +1602

    System.Web.SessionState.SessionStateItemCollection.WriteValueToStreamWithAssert(Object value, BinaryWriter writer) +34
    System.Web.SessionState.SessionStateItemCollection.Serialize(BinaryWriter
    writer) +627

    StateMirror.Client.SessionState.SessionStateUtility.Serialize(SessionStateStoreData item, Stream stream) +338

    StateMirror.Client.SessionState.SessionStateItemWrapper2.SerializeData(Stream
    stream, Boolean compress) +397
    StateMirror.Client.CommonStoreAPI.SetItemInternal(String id,
    CommonItemWrapperBase itemWrapper, Boolean inStorage, Boolean sendIsHave,
    Msg& checkReq, Msg& setReq) +1814
    StateMirror.Client.SessionStateStoreAPI.SetItem(String id,
    CommonItemWrapperBase itemWrapper, Boolean inStorage) +168

    StateMirror.Client.SessionState.SessionStateStoreProvider.SetAndReleaseItemExclusive(HttpContext
    context, String id, SessionStateStoreData item, Object lockId, Boolean
    newItem) +224

    StateMirror.Client.SessionState.SessionStateStoreProvider.SaveAppState(HttpContext context) +435

    StateMirror.Client.SessionState.SessionStateStoreProvider.EndRequest(HttpContext context) +50
    System.Web.SessionState.SessionStateModule.OnEndRequest(Object source,
    EventArgs eventArgs) +214

    System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
    completedSynchronously) +64


    I am using version 2 of the .NET framework and developing in Visual Studio
    2008.

    Thank you
     
    feliz, Aug 29, 2008
    #1
    1. Advertising

  2. I can't reproduce this by using the Hello, World server created by using
    File->Add New Project->ASP.NET Web Service Project, then setting
    EnableSession=true and session mode="StateServer".

    This looks like a problem with your StateMirror software
    (www.statemirror.com).

    --
    John Saunders | MVP - Connected System Developer

    "feliz" <> wrote in message
    news:...
    > - Create a new webservice project with a webmethod that has enabled
    > sessions
    > (WebMethod(EnableSession=true) attribute).
    > - Set the sessionState mode to any mode other than "InProc".
    > - Run the project (either in IIS or the Development server)
    > - Call the webmethod
    >
    > The request will fail with the following exception:
    >
    > Unable to serialize the session state. In 'StateServer' and 'SQLServer'
    > mode, ASP.NET will serialize the session state objects, and as a result
    > non-serializable objects or MarshalByRef objects are not permitted. The
    > same
    > restriction applies if similar serialization is done by the custom session
    > state store in 'Custom' mode.
    >
    >
    > Stack Trace:
    >
    > [SerializationException: Type 'System.Resources.RuntimeResourceSet' in
    > Assembly 'mscorlib, Version=2.0.0.0, Culture=neutral,
    > PublicKeyToken=b77a5c561934e089' is not marked as serializable.]
    >
    > System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType
    > type) +2700482
    >
    > System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type
    > type, StreamingContext context) +245
    >
    > System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()
    > +88
    >
    > System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object
    > obj, ISurrogateSelector surrogateSelector, StreamingContext context,
    > SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter,
    > ObjectWriter objectWriter) +175
    >
    > System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object
    > obj, ISurrogateSelector surrogateSelector, StreamingContext context,
    > SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter,
    > ObjectWriter objectWriter) +50
    >
    > System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object
    > graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) +438
    >
    > System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream
    > serializationStream, Object graph, Header[] headers, Boolean fCheck) +131
    > System.Web.Util.AltSerialization.WriteValueToStream(Object value,
    > BinaryWriter writer) +1513
    >
    > [HttpException (0x80004005): Unable to serialize the session state. In
    > 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session
    > state
    > objects, and as a result non-serializable objects or MarshalByRef objects
    > are
    > not permitted. The same restriction applies if similar serialization is
    > done
    > by the custom session state store in 'Custom' mode.]
    > System.Web.Util.AltSerialization.WriteValueToStream(Object value,
    > BinaryWriter writer) +1602
    >
    > System.Web.SessionState.SessionStateItemCollection.WriteValueToStreamWithAssert(Object
    > value, BinaryWriter writer) +34
    >
    > System.Web.SessionState.SessionStateItemCollection.Serialize(BinaryWriter
    > writer) +627
    >
    > StateMirror.Client.SessionState.SessionStateUtility.Serialize(SessionStateStoreData
    > item, Stream stream) +338
    >
    > StateMirror.Client.SessionState.SessionStateItemWrapper2.SerializeData(Stream
    > stream, Boolean compress) +397
    > StateMirror.Client.CommonStoreAPI.SetItemInternal(String id,
    > CommonItemWrapperBase itemWrapper, Boolean inStorage, Boolean sendIsHave,
    > Msg& checkReq, Msg& setReq) +1814
    > StateMirror.Client.SessionStateStoreAPI.SetItem(String id,
    > CommonItemWrapperBase itemWrapper, Boolean inStorage) +168
    >
    > StateMirror.Client.SessionState.SessionStateStoreProvider.SetAndReleaseItemExclusive(HttpContext
    > context, String id, SessionStateStoreData item, Object lockId, Boolean
    > newItem) +224
    >
    > StateMirror.Client.SessionState.SessionStateStoreProvider.SaveAppState(HttpContext
    > context) +435
    >
    > StateMirror.Client.SessionState.SessionStateStoreProvider.EndRequest(HttpContext
    > context) +50
    > System.Web.SessionState.SessionStateModule.OnEndRequest(Object source,
    > EventArgs eventArgs) +214
    >
    > System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    > +92
    > System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
    > completedSynchronously) +64
    >
    >
    > I am using version 2 of the .NET framework and developing in Visual Studio
    > 2008.
    >
    > Thank you
     
    John Saunders, Aug 31, 2008
    #2
    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. Carpe Diem
    Replies:
    3
    Views:
    7,188
    Carpe Diem
    Feb 23, 2004
  2. --alec
    Replies:
    0
    Views:
    8,428
    --alec
    Jun 24, 2004
  3. =?Utf-8?B?TkFU?=
    Replies:
    1
    Views:
    382
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Jun 1, 2006
  4. teo
    Replies:
    2
    Views:
    355
    kferron
    Dec 10, 2006
  5. April
    Replies:
    8
    Views:
    4,095
    April
    Jan 24, 2009
Loading...

Share This Page