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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:49:18+00:00 2026-05-18T01:49:18+00:00

What needs to be done in order to serialize enums with protobuf-net? I’m getting

  • 0

What needs to be done in order to serialize enums with protobuf-net? I’m getting the below error when serializing a class having an enum property, if the DataMember attribute is removed from the property declaration it works fine.

“System.InvalidOperationException: Only data-contract classes (and lists/arrays
of such) can be processed”

  • 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-18T01:49:18+00:00Added an answer on May 18, 2026 at 1:49 am

    I suspect they are actually 2 different scenarios, but with regard to the code sample added by Andrew, this is because it can’t figure out (in advance) what it is going to do with regards to default values (by default, data is treated as optional at the receiver). There are 3 ways of fixing this:

    1: add an enum with value 0 (since 0 is always the CLI default value for zeros), for example

    public enum SiteType
    {
        Error = 0,
        ...
    

    2: tell it which value to use by default:

    [ProtoMember(10), DefaultValue(SiteType.Partition)]
    public SiteType Type { get; set; }
    

    3: tell the engine that it really doesn’t need to worry about it, i.e. that it is going to have a value:

    [ProtoMember(10, IsRequired = true)]
    public SiteType Type { get; set; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project that needs to be done using ASP.NET. Currently, I'm using
I have work that needs to be done in this order: In main activity:
What needs to be done to be able to step-into (F11) the reflected code.
In your opinion, should the documents listing what further needs to be done on
So yea, I suck with regular expressions. Needs to be done with php. Thanks.
I have an object which needs to destroy itself. Can it be done? Is
(Not my real MySQL schema, but illustrates what needs done.) Users can belong to
I have a class PersonList [XmlRoot(Persons)] PersonList : List<Human> when I serialize this to
When Paging needs to be done in an web site... Which method performs better?
I know this is bad practice, but it needs to be done, or I'll

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.