Solved

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

Posted on 2009-07-02
5
1,309 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
error on the asp.net page 1 33
How do ASP.NET and MVC work together? 4 25
C# Single Form 8 26
Automated testing suggestions? 2 22
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

914 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now