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 1094197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:56:20+00:00 2026-05-16T23:56:20+00:00

I’m unable to serialize my class using protobuf-net, the issue seems to be that

  • 0

I’m unable to serialize my class using protobuf-net, the issue seems to be that protobuf-net is unable to serialize the interface.

interface MyInterface
{
    string name;
}

[ProtoContract]
[ProtoInclude(1, typeof(MyClass1))]
[ProtoInclude(2, typeof(MyClass2))]
public abstract class ParentClass
{
    [ProtoMember(1)]
    List<MyInterface> elements;
}


[ProtoContract]
public class MyClass1 : ParentClass, MyInterface
{
    [ProtoMember(1)]
    int x;
}

[ProtoContract]
public class MyClass2 : MyInterface
{
    [ProtoMember(1)]
    string y;
}

I’m unable to serialize any object of type MyClass1, since the elements is a list of interface, which can be Mylass1 or MyClass2. I’m getting some encoding not set error.

Can anyone let me know how I can resolve this. Thanks.

  • 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-16T23:56:21+00:00Added an answer on May 16, 2026 at 11:56 pm

    In the current official versions I don’t include interface serialization support. However, I do have a patch contributed (from another user) that seems to enable this.

    I haven’t applied this patch to the core yet, simply because I need to focus on finishing “v2” first before adding more features (especially as the feature would need to be completely re-implemented for v2), but I’m happy to share the patch with you if you would like.

    Alternatively: use a base-class instead of an interface. That is supported (via [ProtoInclude]) – however, the fact that your MyClass1 already has a parent class complicates matters somewhat.


    Edit: this is now supported in v2. The code must know about the expected concrete implementations, obviously – but includes can now be attached to interfaces (or optionally specified in code for vanilla POCO models).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

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.