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:

> All...
>
> 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
> types.
>
> 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
> file.
>
> Any ideas?  Should it work?
>
> ...Richard
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To post to this group, send email to protobuf@googlegroups.com.
> To unsubscribe from this group, send email to
> protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/protobuf?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to