Frage

Works:

[ProtoContract(ImplicitFields = ImplicitFields.AllPublic)]
public class ExcelData
{
    public int[] DataObjects { get; set; }
}

Don't work:

[ProtoContract(ImplicitFields = ImplicitFields.AllPublic)]
public class ExcelData
{
    public object[] DataObjects { get; set; }
}

My test:

[TestMethod]
public void ProtoWithObjectArray()
{
   var ex = new ProtoBufServiceClient(baseUrl);
   var res = ex.Get(new SelectWorksheetRange());
}

[ProtoContract(ImplicitFields = ImplicitFields.AllPublic)]
public class SelectWorksheetRange : IReturn<ExcelData>
{
}

I don't even see error, because test just finish at ex.Get without any information. How to debug this?

War es hilfreich?

Lösung

I cannot comment on ServiceStack, but as far as protobuf-net is concerned, yes: "int[] good, object[] bad". The reason is that the protobuf wire format (as designed by Google) is very terse and includes precisely zero metadata: it expects both ends of any conversation to know exactly what they are exchanging at any point. With int[], that is possible, and with object[] it simply isn't. There are some nasty ways of hacking around it, but they tend to be problematic (maintenance-wise) and inefficient.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top