msgpack-cli
msgpack-cli copied to clipboard
DataSet serialization
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[...
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!
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.
Thank you for information.