I created a strongly typed dataset using the designer and added a couple of
public properties via the Partial Class. Everything is fine and the
strongly typed data set functions as expected including the public
properties until the serialization/deserialization process. When all the
custom public properties are total ignored and lost. Is this behaviour by
design or simply a bug?

Thanks,

Michael

RE: Serialization Problem: custom properties of a derived DataSet class not serialized by v-kevy

v-kevy
Wed Nov 23 21:35:56 CST 2005

Hi Michael,

Are you using DataSet.WriteXml to serialize the DataSet object? The
DataSet.WriteXml will only write things that defined in DataSet schema
(.xsd file) to the Xml. It is by design.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


RE: Serialization Problem: custom properties of a derived DataSet class not serialized by v-kevy

v-kevy
Wed Nov 23 21:37:51 CST 2005

Also, you can override the WriteXml method in your partial class to get
custom properties serialized.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Re: Serialization Problem: custom properties of a derived DataSet class not serialized by Michael

Michael
Wed Nov 23 22:00:45 CST 2005

Thank, Kevin

It sounds like that I have to overwrite the Dataset.WriteXml to include the
custom properties in the serialization. Do you have a code snippt for this?
I guess that I have to do call the base class WriteXml to serialize
everything specified by the dataset schema, as well as the custom
properties, right?

Michael

"Kevin Yu [MSFT]" <v-kevy@online.microsoft.com> wrote in message
news:$78W9nK8FHA.3380@TK2MSFTNGXA02.phx.gbl...
> Also, you can override the WriteXml method in your partial class to get
> custom properties serialized.
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>



Re: Serialization Problem: custom properties of a derived DataSet class not serialized by Michael

Michael
Wed Nov 23 22:13:11 CST 2005

What if I want use the binaryformatter to serialize?

"Kevin Yu [MSFT]" <v-kevy@online.microsoft.com> wrote in message
news:$78W9nK8FHA.3380@TK2MSFTNGXA02.phx.gbl...
> Also, you can override the WriteXml method in your partial class to get
> custom properties serialized.
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>



Re: Serialization Problem: custom properties of a derived DataSet class not serialized by Cor

Cor
Thu Nov 24 02:24:13 CST 2005

Kevin,

> Are you using DataSet.WriteXml to serialize the DataSet object? The
> DataSet.WriteXml will only write things that defined in DataSet schema
> (.xsd file) to the Xml. It is by design.
>

Is that new, I almost never use a xsd file and do only

ds.WriteXml(path,parameter)

Cor



Re: Serialization Problem: custom properties of a derived DataSet class not serialized by Cor

Cor
Thu Nov 24 02:26:05 CST 2005

Michael,

Are your custom properties part of the dataset or are they outside the
dataset.

In otherwords is your property a column or is it just a property of your
class that you made with it.

AFAIK is a dataset forever a dataset, not a serialized object.

Cor



Re: Serialization Problem: custom properties of a derived DataSet class not serialized by Cor

Cor
Thu Nov 24 02:30:31 CST 2005

Kevin,

Thinking it over I get what you mean and we agree.

> Are you using DataSet.WriteXml to serialize the DataSet object? The
> DataSet.WriteXml will only write things that defined in DataSet schema
> (.xsd file) to the Xml. It is by design.
>
Only you would have better written (by instance a .xsd file) in my opinion.
The schema can as well be a part of the XML file itself.

Cor



Re: Serialization Problem: custom properties of a derived DataSet class not serialized by Michael

Michael
Thu Nov 24 03:22:55 CST 2005

The property is unrelated to the dataset but defined as part of the class.
What it does not make any sense to me is that the class is marked as
serializable but the public property is not serialized. This seems
contradict to basic rules of serialization.

"Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
news:O$VKdDN8FHA.3876@TK2MSFTNGP09.phx.gbl...
> Michael,
>
> Are your custom properties part of the dataset or are they outside the
> dataset.
>
> In otherwords is your property a column or is it just a property of your
> class that you made with it.
>
> AFAIK is a dataset forever a dataset, not a serialized object.
>
> Cor
>



Re: Serialization Problem: custom properties of a derived DataSet class not serialized by Cor

Cor
Thu Nov 24 04:05:48 CST 2005

Michael,

Than it is as Kevin asked, did you serialize it with a dataset method or
with a normal serialize method for an object as shown here by instance.

http://www.vb-tips.com/default.aspx?ID=7ffd296f-9e81-47e6-88dc-61641f5c8d9d

I hope that we are in the right direction to the answer.

Cor



Re: Serialization Problem: custom properties of a derived DataSet class not serialized by Michael

Michael
Thu Nov 24 16:08:46 CST 2005

Thanks for the reply.

Neither WriteXml nor normal serialization as the code suggested by your link
does the job. I'm bit frustrated as you and Kevin seemed to know the
anwser, but yet have provided any thing with clearity on this.

Michael


"Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
news:uGw5L7N8FHA.736@TK2MSFTNGP09.phx.gbl...
> Michael,
>
> Than it is as Kevin asked, did you serialize it with a dataset method or
> with a normal serialize method for an object as shown here by instance.
>
> http://www.vb-tips.com/default.aspx?ID=7ffd296f-9e81-47e6-88dc-61641f5c8d9d
>
> I hope that we are in the right direction to the answer.
>
> Cor
>



Re: Serialization Problem: custom properties of a derived DataSet class not serialized by v-kevy

v-kevy
Thu Nov 24 20:07:42 CST 2005

Hi Micheal,

The custom properties are actually a party of the DataSet schema. If you
only write the Xml data, the custom properties will not be persisted. So in
this case if you're serializing your typed DataSet, I suggest you try to
use WriteXml and write the schema info together with the DataSet xml data.
Then when you deserialize it using ReadXml, also read the schema. Here is a
code sample.

DataSet1 ds = new DataSet1();
ds.CustomProperty = "Value";
ds.WriteXml(@"c:\aaa1.xml", XmlWriteMode.WriteSchema);
DataSet1 ds1 = new DataSet1();
ds1.ReadXml(@"c:\aaa1.xml", XmlReadMode.ReadSchema);

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Re: Serialization Problem: custom properties of a derived DataSet class not serialized by Michael

Michael
Thu Nov 24 20:30:41 CST 2005

Thanks Kevin. It worked for me now except:

. The normal serialization does not work.
. I can't binary serialize the typed dataset with custom public properties.
. If the public property is Int16, it still does not get serialized.

So I can work around my problem now, but this still suggests that it's not
ideal if not a bug.

Michael

"Kevin Yu [MSFT]" <v-kevy@online.microsoft.com> wrote in message
news:BRx9PUW8FHA.1240@TK2MSFTNGXA02.phx.gbl...
> Hi Micheal,
>
> The custom properties are actually a party of the DataSet schema. If you
> only write the Xml data, the custom properties will not be persisted. So
> in
> this case if you're serializing your typed DataSet, I suggest you try to
> use WriteXml and write the schema info together with the DataSet xml data.
> Then when you deserialize it using ReadXml, also read the schema. Here is
> a
> code sample.
>
> DataSet1 ds = new DataSet1();
> ds.CustomProperty = "Value";
> ds.WriteXml(@"c:\aaa1.xml", XmlWriteMode.WriteSchema);
> DataSet1 ds1 = new DataSet1();
> ds1.ReadXml(@"c:\aaa1.xml", XmlReadMode.ReadSchema);
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>



Re: Serialization Problem: custom properties of a derived DataSet class not serialized by v-kevy

v-kevy
Sun Nov 27 20:43:54 CST 2005

Thank you Michael for your feedback. I will forward this to the appropriate
team.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."