473,320 Members | 1,978 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,320 software developers and data experts.

Serializing classes derived from dataset

Hi,

I am trying to store various objects within session. Due
to the site being hosted in a web farm we are going to
have to use either State Server or SQL Server to persist
the data in session. All of the objects are classes which
inherit from a typed dataset.

Looking at MSDN I have found the following two (what I
believe to be) relevent statements (from article Object
Serialization in the .NET Framework):

"Derived classes should call the GetObjectData method on
the base object if the latter implements ISerializable"

and

"When you derive a new class from one that implements
ISerializable, the derived class must implement both the
constructor as well as the GetObjectData method if it has
any variables that need to be serialized."

Since the Dataset implements ISerializable the above
statements indicate that I should override the
GetObjectData method. However if I try and override this
method I get a compile error stating:

"sub 'GetObjectData' cannot be declared 'Overrides'
because it does not override a sub in a base class."

I am also unable to call the method GetObjectData on the
base class as it is not accessible.

The classes which I am trying to persist have their own
properties, some of which are themselves objects which
inherit from datasets.

If I create a test class which inherits from a typed
dataset, and which has two additional properites (named
Property1 and Property2) the following XML is persisted:

<?xml version="1.0" encoding="utf-16"?>
<xs:schema id="dsTemp"
targetNamespace="http://tempuri.org/dsTemp.xsd"
xmlns:mstns="http://tempuri.org/dsTemp.xsd"
xmlns="http://tempuri.org/dsTemp.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified"
elementFormDefault="qualified">
<xs:element name="dsTemp" msdata:IsDataSet="true"
msdata:Property1="1" msdata:Property2="Aidan">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="InvoiceHeader">
<xs:complexType>
<xs:sequence>
<xs:element name="InvoiceHeaderID"
msdata:ReadOnly="true" msdata:AutoIncrement="true"
type="xs:int" />
<xs:element name="POHeaderID" type="xs:int"
minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="dsTempKey1" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:InvoiceHeader" />
<xs:field xpath="mstns:InvoiceHeaderID" />
</xs:unique>
</xs:element>
</xs:schema>

Note that the properties have been serialized, but have
been serialized as "<xs:element name="dsTemp"
msdata:IsDataSet="true" msdata:Property1="1"
msdata:Property2="Aidan">"

I can find no way in which I can de-serialize these fields.

Can someone please explain how I can have a class which
inherits from a dataset, and which I can then serialize
and de-serialize without losing the properties.

Thanks in advance

Aidan
Nov 17 '05 #1
1 2558
Note that the xml which should have been displayed
indicated that the properties were included in a dataset
element as

msdata:Property1="1"
msdata:Property2="Aidan"

-----Original Message-----
Hi,

I am trying to store various objects within session. Due
to the site being hosted in a web farm we are going to
have to use either State Server or SQL Server to persist
the data in session. All of the objects are classes whichinherit from a typed dataset.

Looking at MSDN I have found the following two (what I
believe to be) relevent statements (from article Object
Serialization in the .NET Framework):

"Derived classes should call the GetObjectData method on
the base object if the latter implements ISerializable"

and

"When you derive a new class from one that implements
ISerializable, the derived class must implement both the
constructor as well as the GetObjectData method if it has
any variables that need to be serialized."

Since the Dataset implements ISerializable the above
statements indicate that I should override the
GetObjectData method. However if I try and override this
method I get a compile error stating:

"sub 'GetObjectData' cannot be declared 'Overrides'
because it does not override a sub in a base class."

I am also unable to call the method GetObjectData on the
base class as it is not accessible.

The classes which I am trying to persist have their own
properties, some of which are themselves objects which
inherit from datasets.

If I create a test class which inherits from a typed
dataset, and which has two additional properites (named
Property1 and Property2) the following XML is persisted:

<?xml version="1.0" encoding="utf-16"?>
<xs:schema id="dsTemp"
targetNamespace="http://tempuri.org/dsTemp.xsd"
xmlns:mstns="http://tempuri.org/dsTemp.xsd"
xmlns="http://tempuri.org/dsTemp.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified"
elementFormDefault="qualified">
<xs:element name="dsTemp" msdata:IsDataSet="true"
msdata:Property1="1" msdata:Property2="Aidan">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="InvoiceHeader">
<xs:complexType>
<xs:sequence>
<xs:element name="InvoiceHeaderID"
msdata:ReadOnly="true" msdata:AutoIncrement="true"
type="xs:int" />
<xs:element name="POHeaderID" type="xs:int"
minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="dsTempKey1" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:InvoiceHeader" />
<xs:field xpath="mstns:InvoiceHeaderID" />
</xs:unique>
</xs:element>
</xs:schema>

Note that the properties have been serialized, but have
been serialized as "<xs:element name="dsTemp"
msdata:IsDataSet="true" msdata:Property1="1"
msdata:Property2="Aidan">"

I can find no way in which I can de-serialize these fields.
Can someone please explain how I can have a class which
inherits from a dataset, and which I can then serialize
and de-serialize without losing the properties.

Thanks in advance

Aidan
.

Nov 17 '05 #2

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

Similar topics

0
by: big A | last post by:
I am receiving an error stating that File or Assembly name <filname.dll>, or one of its dependencies, was not found In one assembly I have three abstract classes In another I have three...
2
by: Aleksei Guzev | last post by:
Imagine one writing a class library CL1 for data storage. He defines classes ‘DataItem’ and ‘DataRecord’ so that the latter contains a collection of the former. And he derives class ‘IntItem’ from...
0
by: Ante Smolcic | last post by:
Hi all, I have an ArrayList that contains items of type A. I declared the XmlArrayItem atribute for that type. Now I have an derived type B (from A) also contained in the ArrayList but I get...
1
by: Ivo Bronsveld | last post by:
All, I have quite a challenging task ahead of me. I need to write an object model (for code access) based on a schema, which cannot be made into a dataset because of it's complexity. So I...
2
by: Mark Olbert | last post by:
I'm confused about the behavior of inherited WebForms under VS/NET 2003. In the Windows.Forms world, if I create a UserControl with a protected component on it, that protected component is...
0
by: Craig Buchanan | last post by:
i am trying to build an application that uses plugins to extend the business functionality of an application. i've decided to use inheritance of abstract classes as the mechanism to do this. ...
2
by: she_prog | last post by:
I have a class derived from UserControl. I need to serialize an object of this class, but only some properties of it, as not all properties are serializable (some of the properties coming from...
12
by: Cagdas Ozgenc | last post by:
Greetings, When directly serializing C++ structures to a file with the standard library functions giving the address of the data and length of structure using the sizeof operator, do I risk...
0
by: Shaul | last post by:
Hi, My goal is to serialize a collection of type IList<AbstractClass> which contains derived objects instances. My domain object model is a bit complex so I've created a demmi one: public...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.