Unable to serialize the session state

J

js

Does anybody knows how to solve the problem? I added [Serializable]
attribute to the following classes in
Microsoft.Practices.EnterpriseLibrary.Data namespace, but I still get
the error. Thanks.

Database.cs
DatabaseFactory.cs
DatabaseProviderFactory.cs
DBCommandWrapper.cs


Server Error in '/' Application.
--------------------------------------------------------------------------------
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'.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: 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'.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.


Stack Trace:


[SerializationException: The type
Microsoft.Practices.EnterpriseLibrary.Data.Database in Assembly
Microsoft.Practices.EnterpriseLibrary.Data, Version=1.0.0.1,
Culture=neutral, PublicKeyToken=60c24972b7c20af7 is not marked as
serializable.]

System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType
type, Boolean excludeNonSerializable) +965

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.Write(WriteObjectInfo
objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo) +515

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

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

[HttpException (0x80004005): 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'.]
System.Web.Util.AltSerialization.WriteValueToStream(Object value,
BinaryWriter writer) +1710
System.Web.SessionState.SessionDictionary.Serialize(BinaryWriter
writer) +148

System.Web.SessionState.StateClientManager.Serialize(SessionStateItem
item, Stream stream) +146

System.Web.SessionState.SqlStateClientManager.System.Web.SessionState.IStateClientManager.Set(String
id, SessionStateItem item, Boolean inStorage) +126
System.Web.SessionState.SessionStateModule.OnReleaseState(Object
source, EventArgs eventArgs) +465
System.Web.SessionState.SessionStateModule.OnEndRequest(Object
source, EventArgs eventArgs) +44

System.Web.SyncEventExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
+60
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously) +87
 
B

Bruce Barker

adding the [Serializable] attribute just says the class can be serialized.
this means when the serialization asks each member to serialize itself, it
does.in addition to addind the attribute, for each member that is not a
serializable datatype, you need to add code to do it. it is unlikely you
can get all these classes to serialze as they contain unmanged resources.


-- bruce (sqlwork.com)




js said:
Does anybody knows how to solve the problem? I added [Serializable]
attribute to the following classes in
Microsoft.Practices.EnterpriseLibrary.Data namespace, but I still get
the error. Thanks.

Database.cs
DatabaseFactory.cs
DatabaseProviderFactory.cs
DBCommandWrapper.cs


Server Error in '/' Application.
--------------------------------------------------------------------------------
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'.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: 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'.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.


Stack Trace:


[SerializationException: The type
Microsoft.Practices.EnterpriseLibrary.Data.Database in Assembly
Microsoft.Practices.EnterpriseLibrary.Data, Version=1.0.0.1,
Culture=neutral, PublicKeyToken=60c24972b7c20af7 is not marked as
serializable.]

System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType
type, Boolean excludeNonSerializable) +965

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.Write(WriteObjectInfo
objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo) +515

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

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

[HttpException (0x80004005): 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'.]
System.Web.Util.AltSerialization.WriteValueToStream(Object value,
BinaryWriter writer) +1710
System.Web.SessionState.SessionDictionary.Serialize(BinaryWriter
writer) +148

System.Web.SessionState.StateClientManager.Serialize(SessionStateItem
item, Stream stream) +146

System.Web.SessionState.SqlStateClientManager.System.Web.SessionState.IStateClientManager.Set(String
id, SessionStateItem item, Boolean inStorage) +126
System.Web.SessionState.SessionStateModule.OnReleaseState(Object
source, EventArgs eventArgs) +465
System.Web.SessionState.SessionStateModule.OnEndRequest(Object
source, EventArgs eventArgs) +44

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

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top