By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,704 Members | 1,122 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,704 IT Pros & Developers. It's quick & easy.

Serializng objects for SQL State management

P: n/a
GSK
Hello all,

I am trying to migrate my site from In-proc state management to out-of-proc
SQL state management.

I am having problems with the serialization of my classes.

I have added the [Serializable] attribute to the classes, which works, but
some of the classes' objects (XmlDocument is one example), are causing
errors:

"[SerializationException: The type System.Xml.XmlDocument in Assembly
System.Xml, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089 is not marked as serializable.]"

Is there a quick way around this? Perhaps creating a derived class from
XmlDocument that is marked as serializable, or is there another attribute or
solution that I am missing?

Thanks for your help,

- gsk
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
If a class isn't serializable, than any classes that derive from it wouldn't
be serializable.
What you could do, though is expose a property for your XmlDocument but have
the document itself strored as a string within the provate variable, so in
your get/set you instantiate an XmlDocument, load it with the string and
then return it to the user.

The problem, though, would be that the string would be passed by value, so
if a process just got the document and modified it, that procedd would have
to re-set the property for the private variable to get the changes.

Another option....

DataSets are serializable, so if your document id structured in a way that
loading it into a dataset wouldn be too strange, that might be a good way of
handling it
"GSK" <gs*@NiOcSaP.nAeMt> wrote in message
news:uh**************@TK2MSFTNGP09.phx.gbl...
Hello all,

I am trying to migrate my site from In-proc state management to out-of-proc SQL state management.

I am having problems with the serialization of my classes.

I have added the [Serializable] attribute to the classes, which works, but
some of the classes' objects (XmlDocument is one example), are causing
errors:

"[SerializationException: The type System.Xml.XmlDocument in Assembly
System.Xml, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089 is not marked as serializable.]"

Is there a quick way around this? Perhaps creating a derived class from
XmlDocument that is marked as serializable, or is there another attribute or solution that I am missing?

Thanks for your help,

- gsk

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.