Groups | Blog | Home
all groups > dotnet xml > may 2004 >

dotnet xml : Xsd and serialisation


questions NO[at]SPAM resolutionsnet.co.uk
5/29/2004 3:09:53 AM
hello,

I wonder if anyone can help me.

I have used xsd to generate a c# class from an xml file.

This class is currently being used in my application and works
perfectly ok when stored in InProc session.

But when moving to StateServer, it throws the "Unable to serialize the
session state", now I know the reasons why it throws this error. But I
have a very simple xml structure (and in turn a simply generated
class).

Can anyone help me.

The XML structure is simple, i.e.


<AAAs>
<AAA Name="x" Type="y">
<BBB x="1" />
<CCC x="1" y="2"/>
<CCC x="2" y="3"/>
</AAA>

<AAA Name="x" Type="y">
<BBB x="1" />
<CCC x="1" y="2"/>
<CCC x="2" y="3"/>
</AAA>
</AAAs>


And I am loading it like this;

MmlSerializer serializer = new XmlSerializer(typeof(AAAs));

// Read in the XML document
FileStream fs = new FileStream( filepath )

// Declare an object variable of the type to be deserialized.
AAAs newobject

// Use the Deserialize method to restore the object's state with data
from the XML document.

newobject = (AAAs)serializer.Deserialize(fs);

Session["AAAs"] = newobject;


Can anyone help, I'd really like to get this working with StateServer
rather than InProc.

Christoph Schittko [MVP]
6/3/2004 8:23:53 PM
Tony,

You can add the [Serializable] attribute to the classes generated by XSD.exe
to make them compatible with StateServer, or you can serialize your
instances to a string and store the string in the session.

--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

[quoted text, click to view]

AddThis Social Bookmark Button