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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:05:04+00:00 2026-05-22T21:05:04+00:00

Using latest 2.0 beta version of ProtoBuf.net I am trying to serialize derived class(just

  • 0

Using latest 2.0 beta version of ProtoBuf.net I am trying to serialize derived class(just example) and I get empty file. Why base class properties is not serialized?

[ProtoContract]
[Serializable]
public class Web2PdfClient : Web2PdfEntity
{

}

[ProtoContract]
[Serializable]
public class Web2PdfEntity : EngineEntity
{

    [ProtoMember(1)]
    public string Title { get; set; }
    [ProtoMember(2)]
    public string CUrl { get; set; }
    [ProtoMember(3)]
    public string FileName { get; set; }

}


[ProtoContract]
[Serializable]
public class EngineEntity
{

    public bool Result { get; set; }
    public string ErrorMessage { get; set; }
    public bool IsMembershipActive { get; set; }
    public int ConversionTimeout { get; set; }
    public byte[] FileStorage { get; set; }
}

While using code below to serialize class I get empty file.

var Web2PDF = new Web2PdfClient
                          {                                
                              CUrl = "http://www.google.com",
                              FileName = "test.txt"
                          };
        using (var file = File.Create(@"C:\Users\Administrator\Projects\temp\test.bin"))
        {
            Serializer.Serialize(file, Web2PDF);

        }
  • 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-22T21:05:05+00:00Added an answer on May 22, 2026 at 9:05 pm

    Actually, I’m quite surprised that didn’t throw an exception – I will investigate! In order for that to work, the base-type must have a unique way to indicate each of the sub-types. This can be specified via attributes, or (in v2) at runtime. For example:

    [ProtoContract]
    [Serializable]
    public class Web2PdfClient : Web2PdfEntity
    {
    
    }
    
    [ProtoContract]
    [ProtoInclude(7, typeof(Web2PdfClient))]
    [Serializable]
    public class Web2PdfEntity : EngineEntity
    { ... }
    

    There’s nothing special about 7 except that it shouldn’t collide with any other members defined for that type. Multiple subtypes can be defined (with different tags). Note also that protobuf-net doesn’t look at [Serializable], so you don’t need that unless you are also using BinaryFormatter (or similar).

    Similarly, EngineEntity should advertise its expected subtypes, and should indicate the members to serialize (and against which tag).

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

Sidebar

Related Questions

I have a small ASP.NET MVC application developed using the latest beta version. What
I'm trying to get the font-weight of a property using latest jquery, doesn't work
I'm trying the latest Entity Framework Migrations beta 01 release. It works fine using
I'm trying to serialize some objects with protobuf-net , but unfortunately they make liberal
Using the latest version of Resharper (4.5.x) with VS2008. Every now and then (pretty
I'm using the latest nightly build, VS2008 prof trial and .NET 3.5 and I'm
I am using the latest NHibernate 2.1.0Beta2. I'm trying to unit test with SQLite
I'm using XAMPP (latest version) on OS 10.6.2, that's bundled with PHP 5.3.0 I
Hello i am using the latest version of artoolkit, and succesfully compiled simplevrml, but
I'm using the latest indy snapshot (installed yesterday) and newest SSL libraries. When trying

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.