Serializng objects for SQL State management

G

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
 
D

David Jessee

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,165
Latest member
JavierBrak
Top