Solved

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

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

12 Experts available now in Live!

Get 1:1 Help Now