Session serialization error when sessionState mode is not "InProc"

F

feliz

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

John Saunders

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 said:
- 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
 

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

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top