I think I can answer my own question.

Any is not meant to be a 'blob' field type -but rather capture another 
Message whose .proto you do not have on hand.

Instead I should define my RangeData as:

message RangeData { 
int32 rows = 1;
int32 columns = 2;
bytes data = 3;
}


On Monday, October 26, 2015 at 11:55:14 AM UTC-4, Rob Cecil wrote:
>
> I would like to work with Any in a Message declaration:
>
> message RangeData { 
> int32 rows = 1;
> int32 columns = 2;
> google.protobuf.Any data = 3;
> }
>
> In the application, RangeData.data contains two-dimensional tabular data - 
> floats, ints, string.
>
> I can get my data into a byte[] array, but I'm not clear what is the API 
> to populate RangeData:
>
> var rd = new RangeData
> {
>    Rows = 100,
>    Columns = 100,
>    Data = ?
> }
>
> Do I use MergeFrom(this IMessage source, byte[] data) extension method? It 
> looks like at minimum I would need to do this:
>
> var rd = new RangeData
> {
>    Rows = 100,
>    Columns = 100,
>    Data = new Google.Protobuf.WellKnownTypes.Any(); 
> };
>
> rd.Data.MergeFrom(myByteArray);
>
> But I'm getting an exception:
>
> InvalidProtocolBufferException - Protocol message contained an invalid 
> tag(zero).
>
> ~~~
>
> Thanks for your help
> Rob
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to