I am in sitaution where I need to use an external session state server, which requires all my sessions to be serialized. I am trying to make all classes that I store in sessions serializable using an attribute [Serializeable()].
However, I keep getting the following error:
Unable to serialize session state.
In StateServerand mode , SQLServerASP.NET will serialize session state objects, and as a result, serializable objects or objects are not allowed MarshalByRef. The same restriction applies if such serialization is performed by the user session state store in the <mode Custom.
More interesting is the stack trace:
[SerializationException: Enter "ASP.useroverview_aspx" in Assembly 'App_Web_pwonykbc, Version = 0.0.0.0, Culture = neutral, PublicKeyToken = null' is not marked as serializable.]
System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers (RuntimeType type) +9452985
System.Runtime.Serialization.FormatterServices.GetSerializableMembers (Type Type, StreamingContext context) +247
System.Runtime.Serialization.Formattersbject.foinfo.fo
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize (Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, converter IFormatterConverter, ObjectWriter objectWriter, SerializationBinder Binder) +218
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write (WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo) +388
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize (object graph, header [] inHeaders, __BinaryWriter serWriter, Boolean fCheck) +444
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (Stream serializationStream, Object graph, Header [] headers, Boolean fCheck) +133
System.Web.Util.AltSerialization.WriteValueToStream (object value, writer BinaryWriter) +1708
Type ASP.useroverview_aspxis as far as I know the ASPX page. Downloadable page Useroverview.aspx. However, I am not trying to save this page in a session. So this mistake makes me wonder quite a bit.
I tried to do the following in code:
[Serializable()]
public partial class UserOverview : Page
{
private static readonly int TimerInterval = HttpContext.Current.IsDebuggingEnabled ? 2000 : 750;
}
It did not help!
So, I wonder if it is possible to serialize an ASPX page? It does not know if this will make sense. I doubt it!
Thank...