Serializing-Deserializing Extended Dataset

  • Thread starter Thread starter Javed
  • Start date Start date
J

Javed

I subclass a Typed Dataset and add a few fields to some
of the DataTables, add a few DataRelations, and add some
ExtendedProperties. I mark my Class with the
<Serializable> attribute.

On the Client end, however, I get:
An unhandled exception of
type 'System.Runtime.Serialization.SerializationException'
occurred in mscorlib.dll
Additional Info: The constructor to deserialize an object
of type [myDataSetExt] was not found.

What am I missing? Thanks for any help.
 
Hi Javed,

This is a known issue. The DataSet doesn't allow the derived class to
override its ISerializable.GetObjectData() method.

Based on the above, we cannot use derivation to achieve our goal. The
workaround is to use composition. That is, we will not derive from the
DataSet class, instead, we can wrap it, like below:
Public Class ValidationDS
{
Protected DataSet ds;
......
}

This way, we do not need to implement our custom serialization logic (using
the GetObjectData method).

If you want to know more about serialization, please check the following
links:

Run-time Serialization
http://msdn.microsoft.com/msdnmag/issues/02/04/net/

Run-time Serialization, Part 2
http://msdn.microsoft.com/msdnmag/issues/02/07/net/

Run-time Serialization, Part 3
http://msdn.microsoft.com/msdnmag/issues/02/09/net/

Kevin Yu
========
This posting is provided "AS IS" with no warranties, and confers no rights.
 
If you include the dataSet as a private member of another class, how do
you expose its functionality? Do you expose it as a property? Or do
you recode itsinterface making calls to the private member?

If you expose it as a property, can you handle its events?

I am looking for the most efficient way to extend typed datasets. I
have not found any articles on this so far. The serialization issue
seems to rule out inheritance. If Aggregation is the best approach, can
you give a few more hints about how to best expose the functionality of
the dataset?

thnx
Keith
 
Back
Top