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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:58:03+00:00 2026-05-25T20:58:03+00:00

How to I serialize an object like this with protobuf-net: public class MyObject{ public

  • 0

How to I serialize an object like this with protobuf-net:

public class MyObject{
   public string Key {get; set;}
   public List<Object> Values {get; set;}
}

When I try to serialize this with a TypeModel protobuf-net throws an error stating that it doesn’t know how to serialize System.Object. Now I know that Values will only ever contain primitives (int, string, float, DateTime, etc.). So how do I let protobuf-net know about this?

  • 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-25T20:58:04+00:00Added an answer on May 25, 2026 at 8:58 pm

    This isn’t really doable in pure ProtoBuf, in any sense. ProtoBuf is strongly typed, yet does not contain type information in the message; type information is always specified externally. Thus there are two “good” solutions; Ie, solutions which would be easy to interpret by a protobuf implementation other than Protobuf-net (Which you may or may not care about, but marc sure seems to).

    1: Replace List<object> with List<PrimitiveType> where PrimitiveType contains optional fields corresponding to all the 12-or-so primitive types (Depending on your definition of “Primitive Type”.), and you ensure only one of those is filled in on each instance.

    2: Replace List<object> with a combination of List<int>, List<double>, List<string> etc.

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

Sidebar

Related Questions

When serializing, I would like to serialize an object only once, then any references
Is there any way to de/serialize an object without round-tripping a XmlDocument/temp string? I
Is there a way for me to serialize an object in .NET without the
I have a List<object> with different types of objects in it like integers, strings,
I am serializing an object like this: XmlSerializer serializer = new XmlSerializer(obj.GetType()); using (StringWriter
There is this DB-connection-like object that my web application will need. It is pretty
I am trying to serialize some Linq objects using this code. private byte[] GetSerializedObj(object
I would like to serialize and deserialize objects without having to worry about the
I'd like to serialize some LINQ generated objects and store them in a table
The log4j network adapter sends events as a serialised java object. I would like

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.