Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help on debugging or troubleshooting serialization issues (SerializationException: Type System.Xml.XmlElement in Assembly System.Xml)

Posted on 2009-07-02
5
Medium Priority
?
1,386 Views
Last Modified: 2013-11-07
All,
I am stuck trying to convert my web application from using an InProc session management to StateServer.

I have specified all classes that I save to the session as Serializable and specified some of the member variables that cannot be serialized with the [NonSerialized] attribute. But I am still getting the error in the attached file. The stack trace being not very informative, I am not sure where the error is coming from or which class is not getting serialized correctly.

Appreciate any help on debugging or troubleshooting to figure out what causing this. I am not pasting any code as this is a big web application and not just a couple of classes and also since the stack trace is not pointing to any specific class.
Here is the stack trace.
 
[SerializationException: Type 'System.Xml.XmlElement' in Assembly 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.]
   System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type) +7733643
   System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context) +258
   System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() +111
   System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter) +161
   System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter) +51
   System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo) +7631620
   System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) +461
   System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck) +134
   System.Web.Util.AltSerialization.WriteValueToStream(Object value, BinaryWriter writer) +1577
 
[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) +1662
   System.Web.SessionState.SessionStateItemCollection.WriteValueToStreamWithAssert(Object value, BinaryWriter writer) +34
   System.Web.SessionState.SessionStateItemCollection.Serialize(BinaryWriter writer) +606
   System.Web.SessionState.SessionStateUtility.Serialize(SessionStateStoreData item, Stream stream) +239
   System.Web.SessionState.SessionStateUtility.SerializeStoreData(SessionStateStoreData item, Int32 initialStreamSize, Byte[]& buf, Int32& length) +72
   System.Web.SessionState.OutOfProcSessionStateStore.SetAndReleaseItemExclusive(HttpContext context, String id, SessionStateStoreData item, Object lockId, Boolean newItem) +87
   System.Web.SessionState.SessionStateModule.OnReleaseState(Object source, EventArgs eventArgs) +560
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

Open in new window

Stateserver-Error.jpg
0
Comment
Question by:altumadmin
  • 3
  • 2
5 Comments
 
LVL 19

Expert Comment

by:daveamour
ID: 24771263
What are you saving in your Sessions?
0
 

Accepted Solution

by:
altumadmin earned 0 total points
ID: 24934624
I figured out after some debugging that there was code that was trying to serialize an XmlNode.
0
 
LVL 19

Expert Comment

by:daveamour
ID: 24934645
And that isn't serializable?
0
 

Author Comment

by:altumadmin
ID: 24934664
Right, so I changed my code to get the xml as string and rereate the node again.
0
 
LVL 19

Expert Comment

by:daveamour
ID: 24934675
Ok nice one
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Integration Management Part 2
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question