Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I wish to use ASP.Net Session Store to store a value to session. The value or object if you prefer is marked as serializable in order to be placed within the store.

Unfortunately, when running the code I get an unhandled exception error being displayed to the screen. The code itself does not fail at any point in debug. The actual error message in full is "An unhandled exception occurred 'Type 'System.Xml.XmlDocument' in Assembley 'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable"

The problem has been traced back to some properties that are xml documents, which due to session store being binary serialization is not compatible with xml documents. I have overcome the problem by making the xml document a string and then turning back again to xml afterwards.

My question is this, is there a better way of doing this? Surely, I don't need to go through all of this save something to session?
Posted

1 solution

Hi, you can create a class as your return variable that will contain the Xml document, then add a serializable declaration.

C#
[Serializable()]
public class XmlReturnClass  {
   ///Declare Xml here
   ///....
   ///....
}


Good luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900