Below is the class definitions that work and dont' work in a WCF environment running protobuf-net version 2.0.0.480.
Know that the processing code populates the response's list with the real type in hand, in this case SomeClassRow.
And the more bizare thing is that with the bad version of the SomeResponse, the WCF sometimes worked and sometimes didn't.
This is why I use the IDataRow interface. This lets my response's list to hold any types of rows.
So the question is, why is protobuf failing to deserialize when the list is defined with strong type vs. the interface (IDataRow) ?
Thanks,
Ninos
[ProtoContract]
[ProtoInclude(101, typeof(BaseClassInfo))]
public interface IDataRow
{
}
[ProtoContract]
[ProtoInclude(101, typeof(SomeClassRow))]
public class BaseClassInfo : IDataRow
{
[ProtoMember(1)]
public int SomeId { get; set; }
...
}
// This version of the class won't work because it defines the collection with the
// strongly type name i.e. List<Some
[ProtoContract]
public class SomeResponse
{
[ProtoMember(1)]
public List<SomeClassRow> Rows { get; set; }
...
}
// SomeClassRow is in turn an IDataRow.
[ProtoContract]
public class SomeClassRow : BaseClassInfo
{
[ProtoMember(1)]
public string Name { get; set; }
[ProtoMember(2)]
public int Value { get; set; }
...
}
// But, if the response is defined as follows then the WCF deserializes correcty and ALWAYS.
[ProtoContract]
public class SomeResponse
{
[ProtoMember(1)]
public List<IDataRow> Rows { get; set; }
...
}