msgpack-cli icon indicating copy to clipboard operation
msgpack-cli copied to clipboard

DataSet serialization

Open cata02 opened this issue 8 years ago • 2 comments

Hello! I have a large .net project for which i want to use messagepack for wcf serialization. The project uses a lot of untyped DataSets, typed DataSets, and nested DataSets inside POCO. I already have a way of serializing a dataset (typed or not) to a POCO or byte[].

I've created a custom message pack serializer for the base class: DataSet and i'm trying to register it for all untyped DataSets and typed DataSets (which are derived classed from the DataSet class).

I get an exception trying to register the custom message pack serializer for typed datasets.

This line: e.SetSerializer(new MsgPackDatasetSerializer(e.Context));

Throws an exception: 'The serializer must be MsgPack.Serialization.MessagePackSerializer`1[.......] type.'

The class MsgPackDatasetSerializer is my custom serializer which derives from MessagePackSerializer<DataSet> and has a proper implementation.

What are my options? I cannot register a custom serializer for every single typed dataset; there are many of them. :)

Thanks!

cata02 avatar Aug 11 '17 10:08 cata02

I've gone around the problem using reflection. I've created an generic custom serializier that serializes dataset instances using BinaryFormatter that i am instancing using reflection and MakeGeneric on specific type.

cata02 avatar Aug 22 '17 06:08 cata02

Thank you for information.

yfakariya avatar Aug 25 '17 11:08 yfakariya