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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:25:56+00:00 2026-05-23T07:25:56+00:00

I am using v2 rev 421. When I saved the stream produced by protobuf-net

  • 0

I am using v2 rev 421.
When I saved the stream produced by protobuf-net and put it through the strings utility, it discovered many duplicate strings. I am talking about the strings produced by the application, which can be interned, but the string interning does not seem to be on by default.

How do I enabled it?

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-23T07:25:57+00:00Added an answer on May 23, 2026 at 7:25 am

    There are two separate types of interning here; there’s interning while deserializing – this is always enabled, so if duplicates are in the data, you should only see a single .NET string instance in your managed classes, re-used as many times as needed.

    UPDATE for 3.x
    String interning is no longer enabled by default. To enable it set the following in your model.

    RuntimeTypeModel.Default.InternStrings = true;
    

    There is also interning while serializing, to avoid duplicating data into the stream while serializing. This is not on by default, for the simple reason that no such behaviour is defined in the protobuf spec; protobuf-net tries to stay inside the spec by default, only using extensions on an opt-in basis.

    If you want to enable this for protobuf-net=to=protobuf-net usage, then enable the AsReference option for any given string:

    [ProtoMember(13, AsReference = true)]
    public string Foo { get; set; }
    

    This uses a protobuf-net implementation-specific representation. It won’t play very nicely for interop purposes, however. If you need this in an interoperable way, the only thing to do is store the lists separately (perhaps in a List<string> somewhere), and use the position in the list in your data, i.e.

    // this is .... uglier, but probably easier if you need cross-platform
    public int FooOffset {
        get { return Foos.IndexOf(Foo); }
        set { Foo = Foos[value]; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using Sitecore.NET 5.3.1 (rev. 071114) and we found out a problem. When
I'm using the last svn revision of grappelli and rev 11840 of django (before
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using VS2008, C#, .Net 2 and Winforms how can I make a regular Button
While working through Real World Haskell, I tried to complete the palindrome exercise using
Using CouchDB 1.0.1. I have DELETEd some documents, then I PUT some other documents
I want to be able to read vCard and vCalendar data using .NET, I
I am using p4.net API to generate some reports from the metadata. In one
I'm using a RegularExpressionValidator in ASP.NET on a textbox that requires 10 numbers as

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.