Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6378501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:00:55+00:00 2026-05-25T02:00:55+00:00

I have developed an application that is meant to send data from client to

  • 0

I have developed an application that is meant to send data from client to server and back etc. using serialized objects.

For this application, I decided that protobuf-net would be a good option (especially as it handles variable-length objects so well).

However, when sending an object from client to server or vica-versa, all I know is that the object will be some child class of ‘ReplicableObject’. Hence, I am using:

Serializer.SerializeWithLengthPrefix(stream, ro, PrefixStyle.Base128);

Where ‘ro’ is an object of a type that subclasses from ReplicableObject.

However, I get this exception:

An unhandled exception of type ‘ProtoBuf.ProtoException’ occurred in
protobuf-net.dll

Additional information: Unexpected type found during serialization;
types must be included with ProtoIncludeAttribute; found MessageObject
passed as ReplicableObject

In this particular instance, I’m trying to send a MessageObject.

As there is precious little documentation for protobuf-net, I am stuck on what to do. I’ve tried a few attributes here and there to no avail.

Any help appreciated.

Edit: I should make it clear that the subclasses might not even be ones that I’ve written.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:00:56+00:00Added an answer on May 25, 2026 at 2:00 am

    Protobuf is a contract-based serialization format, designed to be platform independent. As such, no type metadata is included on the wire as it would not apply between platforms. Even inheritance is not part of the core protobuf spec.

    protobuf-net as a specific implementation introduces support for inheritance (via some smoke and mirrors), but ideally it should still be possible to define the expected types in advance – exactly the same as other serializers such as XmlSerializer or DataContractSerializer. This can be done by using [ProtoInclude(...)] to specify the anticipated concrete types.

    If you genuinely can’t tell the actual types in advance, there is also a DynamicType option, which writes the AssemblyQualifiedName into the stream. If you are interested in this route, then note that the “cross-platform” features of the format start to break down, but it is very useful for .NET-to-.NET purposes.

    At the simplest, a wrapper such as:

    [ProtoContract]
    public class SomeWrapper {
         [ProtoMember(1, DynamicType = true)]
         public object Value {get;set;}
    }
    

    Wrap your object in that and it should behave (in v2 at least; DynamicType did not exist in v1). Full example:

    [TestFixture]
    public class SO7218127
    {
        [Test]
        public void Test()
        {
            var orig = new SomeWrapper {Value = new SubType { Foo = 123, Bar = "abc"}};
            var clone = Serializer.DeepClone(orig);
            Assert.AreEqual(123, orig.Value.Foo);
            Assert.AreEqual("abc", ((SubType) clone.Value).Bar);
        }
        [ProtoContract]
        public class SomeWrapper
        {
            [ProtoMember(1, DynamicType = true)]
            public BaseType Value { get; set; }
        }
        [ProtoContract]
        public class BaseType
        {
            [ProtoMember(1)]
            public int Foo { get; set; }
        }
        [ProtoContract]
        public class SubType : BaseType
        {
            [ProtoMember(2)]
            public string Bar { get; set; }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed a web application that uses a web server and database hosted
Ok, I have developed this WinForms client, which interacts with a server (ASPX Application)
I have a webserver application developed using idHttpServer. When a client connects do my
I have inherited a VB6/Access application that we have developed and sold for many
I am looking at globalizing an application that I have developed in asp.net mvc.
I have developed a web application and various clients can store records to that
I have an application that was developed for Linux x86 32 bits. There are
I have a windows application that acts as a WCF Service that I developed
I have a web application developed with ASP.net and C# that is running on
We have built a hosted web application, that is developed in a way that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.