Do contained types within a serializable object also have to be
serializable in order for the serialization to work?

No - this is not relevant . If you look into the .NET code you will see that
if you serialize a DataTable it converts it ot a DataSet first which then
renders it as an XML schema and an XML data document of the dataset which
are finally sent. Hence DataTables are never serialised.

Regarding your question it depends on whether it inherits from
MarshalByReference or by value. If a contained type  is MarshalByReference
it will just serialise the reference.

If so, why is serialization of a ST DataSet successful, when its
contained types (ST DataTables) are not marked serializable?

Explained above.

-----Original Message-----
From: Moderated discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED]]On Behalf Of Dan Green
Sent: Tuesday, 25 June 2002 7:40 PM
To: [EMAIL PROTECTED]
Subject: Re: [ADVANCED-DOTNET] Strongly Typed DataTables aren't
serializable - why?


Chad,

> Have you ever looked at the generated code for a Strongly Typed (ST)
> DataSet?

Yes.  Thanks for asking.  If you check, you may even notice many of the
facts you mention in my previous two posts. :)

> The GetChanges() method on
> the DataSet and DataTable returns an instance that is equivalent to
> this.GetType().  Therefore, in the case of the ST DataSet, you are
> getting back the ST DataSet in the GetChanges() call and the same goes
> for the ST DataTable
> This is why you are experiencing the behavior you describing.

Unfortunately, I'm still not seeing it.  To help me out, let me ask a
question related directly to serialization:

Do contained types within a serializable object also have to be
serializable in order for the serialization to work?
If so, why is serialization of a ST DataSet successful, when its
contained types (ST DataTables) are not marked serializable?

Regardless of all that, my initial primary question of why ST DataTables
aren't marked serializable in the first place remains unanswered.  Could
it be an oversight?  I haven't been prepared to assume that.


Dan Green
[ http://dotnetdan.com -- putting the dan in .net ]

You can read messages from the Advanced DOTNET archive, unsubscribe from
Advanced DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to