0

I trying to create a serializer like this

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

It will serialize the class tickdata.

namespace TickDataDefinition
{
public class tickdata
{
    public List<data> _data=new List<data>();        
    public int returncount()
    {
        return _data.Count;
    }
}

public class data
{
    enum type { trade, quote }

    long time;
    double bid1;
    double ask1;
    double bidsize;
    double asksize;
    double price;
    uint size;

    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;
    }

}

}

Strangely this code does not work. The error is "Exception has been thrown by the target of an invocation."

user3398315
  • 331
  • 6
  • 17

1 Answers1

0

I am not sure if I understood the exception, but try this:

In most serializations you should have parameterless constructors in your classes. Add below constructor,

public data()
{

}

As far as I know serialization classes use this constructor to create an instance.

serdar
  • 1,564
  • 1
  • 20
  • 30