Serialization in C#

Hi,

I'm trying to serialize the internal state of the board so that I can download logged data after disconnecting/reconnecting (in C#, UWP). But no matter what I do, it seems that deserializing the object fails with a SerializationException exception. So I boiled it down to a minimal example where this happens:

var board = MbientLab.MetaWear.Win10.Application.GetMetaWearBoard(device);
await board.InitializeAsync();
await board.SerializeAsync();
await board.DeserializeAsync(); // <- An exception of type 'System.Runtime.Serialization.SerializationException' occurred in System.Private.CoreLib.ni.dll but was not handled in user code: Deserialized object with reference id 'i52' not found in stream.

Even if I try to clear the board state from all routes/etc via board.TearDown() before serializing, I still get the same exception as follows:

var board = MbientLab.MetaWear.Win10.Application.GetMetaWearBoard(device);
await board.InitializeAsync();
board.TearDown();
await board.SerializeAsync();
await board.DeserializeAsync(); // <- same exception thrown

I'm using C# API v0.2.0 (using NuGet) and MetaMotionR board model# 5 with FW revision 1.3.4 and HW revision 0.2.

Your assistance is appreciated in advance.


Comments

  • Hrm, it seems that using DataContract serialization with PreserveObjectReferences = true does not properly serialize the data on UWP, which is a problem since the unit tests generate completely different files.

    I'll will have to experiment with another serialization library like JSON.net if this issue persists through the Fall Creator's update.
  • edited October 2017
    Thank you, Eric.

    Please keep us posted on any developments.
  • The Fall Creator's Update fixes DataContract serialization for UWP.   All you have to is update your app's min and target version to build 16299.
This discussion has been closed.