Hi,
My application is devloped using Asp.net 2.0. I am storing session state in sql server.For that i added a web.config entry
< sessionState mode="SQLServer" stateConnectionString="tcpip=localhost:42424" sqlConnectionString="data source=.localhost;integrated security=true" cookieless="false" timeout="20" />
Sql server is configured for persistent storage of session data
I am storing object of the class in the session state.
Class1 obj =new Class1()
Session["Key"] =obj;
Class1and the consecutive members is marked as serializable.
I am the getting the following Error
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 is shown below
[SerializationException: Type 'System.Runtime.Serialization.SerializationInfo' in Assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.] System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +1779970 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +826 System.Runtime.Serialization.ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) +0 System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter) +281 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.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo) +411 System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) +489 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 System.Web.SessionState.SessionStateUtility.Serialize(SessionStateStoreData item, Stream stream) +257 System.Web.SessionState.SessionStateUtility.SerializeStoreData(SessionStateStoreData item, Int32 initialStreamSize, Byte[]& buf, Int32& length) +60 System.Web.SessionState.SqlSessionStateStore.SetAndReleaseItemExclusive(HttpContext context, String id, SessionStateStoreData item, Object lockId, Boolean newItem) +114 System.Web.SessionState.SessionStateModule.OnReleaseState(Object source, EventArgs eventArgs) +355 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64
Can anyone help me regarding this?
Thanks in Advance
Ganesh