Protocol Buffers In C#: How Are Boxed Value Types Handled
Posted
by Greg Dean
on Stack Overflow
See other posts from Stack Overflow
or by Greg Dean
Published on 2009-02-18T19:55:36Z
Indexed on
2010/05/09
4:38 UTC
Read the original article
Hit count: 335
In the following examples:
public class RowData
{
public object[] Values;
}
public class FieldData
{
public object Value;
}
I am curious as how either protobuf-net or dotnet-protobufs would handle such classes. I am more familiar with protobuf-net, so what I actually have is:
[ProtoContract]
public class RowData
{
[ProtoMember(1)]
public object[] Values;
}
[ProtoContract]
public class FieldData
{
[ProtoMember(1)]
public object Value;
}
However I get an error saying "No suitable Default Object encoding found". Is there an easy way to treat these classes, that I am just not aware of?
To elaborate more on the use case:
This is a scaled down version of a data class used in remoting. So essentially it looks like this:
FieldData data = new FieldData();
data.Value = 8;
remoteObject.DoSomething(data);
Note: I've omitted the ISerializable implementation for simplicity, but it is as you'd expect.
© Stack Overflow or respective owner