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, b
ut
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,
- gskIf 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" <gsk@.NiOcSaP.nAeMt> wrote in message
news:uhZriNoOEHA.3300@.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
>
Or another option is to just output the XML Document as a string
containing the XML.
That should Serialize fine.
Hth,
Phil Winstanley
Microsoft ASP.NET MVP
Thanks guys,
As I already had a method for returning the OuterXml of the XmlDocument,
saving that value in session, then subsequently re-creating my object using
the string as an input parameter has done the trick.
Thanks for the advice!
- gsk.
"Phil Winstanley [Microsoft MVP]" <phil@.winstanley.name> wrote in messag
e
news:c85a58$obm@.odah37.prod.google.com...
> Or another option is to just output the XML Document as a string
> containing the XML.
> That should Serialize fine.
> Hth,
> Phil Winstanley
> Microsoft ASP.NET MVP
>
Thursday, March 22, 2012
Serializng objects for SQL State management
Labels:
asp,
in-proc,
management,
migrate,
net,
objects,
out-of-procsql,
serialization,
serializng,
sql,
state
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment