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

  • SEARCH
  • Home
  • 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 6060557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:50:22+00:00 2026-05-23T08:50:22+00:00

To Serialize a class with protobuf-net, you neet to provide the class and property

  • 0

To Serialize a class with protobuf-net, you neet to provide the class and property attributes [ProtoContract] and [ProtoMember(n)] — where n is 1,2,3,..,etc

Appart from cloning to a mirror image of a class, is it possible to serialize/deserialize a class we don’t have control over?

For example:

using ProtoBuf;

  • Serializer.Serialize<Exception>(OutputStream, exception);

or

  • Serializer.Serialize<Tuple<Data,Exception>>(OutputStream, dataWithPossibleException);

NB. say Data has [ProtoContract] / [ProtoMember] and the others do not.

possible approaches:

  • It would be nice if we had “extension attributes” that worked like extension methods. [not possible]
  • replicate the class locally and then copy to / from the object before serializing / deserializing [that would work, but productivity goes down]
  • generate an external proto file/definition for the class and store this in resources? [anyone know how to go 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-23T08:50:23+00:00Added an answer on May 23, 2026 at 8:50 am

    There are options in v2 here:

    • you can configure a RuntimeTypeModel telling it about types and members without needing any attributes
    • for types that are awkward, a surrogate can be supplied to make serialization easier (it must have conversion operators to/from the original type)
    • for APIs where the types aren’t static-typed, there is an option to include type metadata

    Now, I think some of that addresses some of your points. If you can fully specify a scenario that is problematic I might be able to be more specific (or think of new ways of torturing the code to make it work).

    But to answer the headline question (non-decorated): yes, in v2

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

Sidebar

Related Questions

Using Protobuf/Protobuf-net and two classes, one base class and the other derived from the
I have problem with deserialization using protobuf-net. I have the following class: [ProtoContract] public
I'm using protobuf-net , and I'm trying to: Generate a C# class from a
I'd like to use protobuf-net to serialize a derived class as its base class.
How to I serialize an object like this with protobuf-net: public class MyObject{ public
I have a class that I serialize, then deserialize using Protobuf-net version r431 (probably
I'm unable to serialize my class using protobuf-net, the issue seems to be that
We are using protobuf-net (and love it!). We now have a protocontract-decorated child class
I am trying to serialize a ItemTransaction and protobuf-net (r282) is having a problem.
I am trying to serialize/deserialize a List as defined below with protobuf-net v2, and

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.