Cannot serialize type 'TickDataDefinition.data' because it does not have any serializable fields nor properties

StackOverflow https://stackoverflow.com/questions/22328596

  •  12-06-2023
  •  | 
  •  

Question

I get this error when I tried to declare the serializer as below. It returns the error which I do not understand what it means.

var serializer = MsgPack.Serialization.MessagePackSerializer.Create<data>();            

Below is the class definition.

using System;
using System.Collections.Generic;
using System.Text;

namespace TickDataDefinition
{
    class data
    {
        private enum type { trade, quote }
        private long time;
        private double bid1;
        private double ask1;
        private double bidsize;
        private double asksize;
        private double price;
        private uint size;
        public data()
        {
        }
        public data(long t, double b, double a, double bs, double ask)
        {
            time = t;
            bid1 = b;
            ask1 = a;
            bidsize = bs;
            asksize = ask;
        }
        public data(long t, double p, uint s)
        {
            time = t;
            price = p;
            size = s;
        }

    }
}
Was it helpful?

Solution

All of the elements of that class are private other than constructors (which can't be serialized anyway, and wouldn't make sense if so). Expose some actually accessible elements and serialize.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top