473,397 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Xsd and serialisation

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.

Thanks
Nov 12 '05 #1
2 1325
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

"Tony" <qu*******@resolutionsnet.co.uk> wrote in message
news:bb**************************@posting.google.c om...
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.

Thanks

Nov 12 '05 #2
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

"Tony" <qu*******@resolutionsnet.co.uk> wrote in message
news:bb**************************@posting.google.c om...
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.

Thanks

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: unknow | last post by:
I want to do a serialisation in pure C++ but i don't know how. Do you have some useful links ? Thanks
2
by: msnews.microsoft.com | last post by:
Hi Here is another EASY question When you serialise an object in .NET, serialisation adds defaut attributes that I dont care EXEMPLE : <root_test...
1
by: lobrys | last post by:
Hi everybody here is a question I have this class that a want to serialize : Public Class BOO <XmlAttributeAttribute()> Public THING As String <XmlElementAttribute("param")> Public p() As...
2
by: lobrys | last post by:
Hi everybody what are the objets for the folowing XML serialisation : (I have problem with "name" and "datatype") <vehicule type="car"> <name datatype="String">Megane</name> </inventory> ...
0
by: Ollie | last post by:
I have been able to get simple circular references to be serialized in xml by using the ImportTypeMapping method on the SoapReflectionImporter class. But I am unable to serialise circular...
1
by: McGiv | last post by:
Hi, I'm trying to serialise some objects and I've can't get the built in serialisation to output exactly what I want. For the moment I'm implementing the IXmlSerializable interface and doing it...
1
by: BrentonMCA | last post by:
I want to be able to serialise an object and then pass the serialisation text as a string to a Web service without serialising to a file first. I also want to be able to deserialise from the text...
2
by: Greg | last post by:
I have a bizarre situation in which serialisation is failing routinely under a specific condition, and I'm wondering if the details ring a bell with anyone here. I have 2 classes that my...
2
by: ashwinij | last post by:
Hello The steps which i am doing in my program 1) I am having an xml file. 2) I am performing some updations in the file using XQueryUtil class from nux package. 3)After that i am...
1
by: OrionLee | last post by:
I am using C# to work with a 3rd party DLL (Nevron Charts), and attempting to serialise it. The serialisation itself is handled somewhere inside the DLL, so to get it to happen you call the Nevron's...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.