Perhaps I should explain my use case a little better.
I have a proto file which is compiled in, for example known.proto
// more stuff here
I also have another proto file which is not compiled in, for example
optional KnownMessage known = 1;
// more stuff here
What I am trying to do is reflect on a message of type UnknownMessage
looking for messages of type KnownMessage. If I find a matching field I am
trying to copy out the KnownMessage so I can use the generated classes on
On Wed, Jan 26, 2011 at 3:34 AM, Kenton Varda <ken...@google.com> wrote:
> They need to have exactly the same Descriptor object. When you create your
> DynamicMessage from the DynamicMessageFactory, pass the Descriptor object
> returned by the generated type's descriptor() or GetDescriptor() method.
> Don't construct a separate Descriptor manually.
> Of course, then the question is, why are you using DynamicMessage if you
> have the generated type compiled in? Is it because you need to access
> extensions that aren't compiled in? In that case, you do need
> dynamically-constructed Descriptor objects. The best way to copy in this
> case is to serialize the message, and then parse it into the other type.
> On Mon, Jan 24, 2011 at 1:34 AM, Richard Spooner <rich...@csick.com>wrote:
>> I am having problems using CopyFrom to copy a dynamic message in to a
>> generated message.
>> I get the following:
>> libprotobuf FATAL google/protobuf/reflection_ops.cc:54] CHECK failed:
>> (to->GetDescriptor()) == (descriptor): Tried to merge messages of different
>> Using GetTypeName() I can verify that the types are the same. I can also
>> be sure that both the dynamic and the generated message use the same proto
>> Any ideas? Should it work?
>> You received this message because you are subscribed to the Google Groups
>> "Protocol Buffers" group.
>> To post to this group, send email to firstname.lastname@example.org.
>> To unsubscribe from this group, send email to
>> For more options, visit this group at
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To post to this group, send email to email@example.com.
To unsubscribe from this group, send email to
For more options, visit this group at