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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:29:24+00:00 2026-06-03T14:29:24+00:00

Symptom: No serializer defined for type: System.Array Since all C# arrays inherit from the

  • 0

Symptom: No serializer defined for type: System.Array

Since all C# arrays inherit from the Array class, I thought that this would be valid in ProtoBuf-net

[ProtoMember(1)]
public Array SomeKindOfArray = new int[]{1,2,3,4,5};

[ProtoMember(2)]
public List<Array> SomeKindOfList = new List<Array>();

Should I register Array with the RuntimeTypeModel?

m.Add(typeof (Array), true);  // does not seem to help

Attempts:

new int[]{1,2,3,4} // works

(object)new int[] { 1, 2, 3, 4 } // does not work

(Array)new int[] { 1, 2, 3, 4 } // does not work

Another possible solution (can’t find the SO url right now):

Have a list of a base type class items.

Wrap each type. e.g.

class TheBase{}

class ArrayOfInt { public int[] value;}

The would then become one of converting to and from a list of wrappers. Is there an easier way forward?

  • 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-06-03T14:29:26+00:00Added an answer on June 3, 2026 at 2:29 pm

    protobuf-net really really wants to understand the data you are serializing; it isn’t enough to have Array, as that can’t map to any protobuf definition. Repeated data (conceptually, arrays) has a very terse and very specific representation in the protobuf specification, which does not allow extra room for saying, on an individual basis, “of [x]”. In protobuf, the “of [x]” is expected to be already known and fixed in advance.

    So:

    [ProtoMember(1)]
    public int[] AnIntegerArray {get;set;}
    
    [ProtoMember(2)]
    public Customer[] ACustomerArray {get;set;}
    

    will work fine. But Array will not work at all.

    Depending on how important this is, there may be other options, for example (and you may want to tweak the names!):

    [ProtoContract]
    [ProtoInclude(1, typeof(DummyWrapper<int>)]
    [ProtoInclude(2, typeof(DummyWrapper<Customer>)]
    public abstract class DummyWrapper {
        public abstract Type ElementType {get;}
    }
    [ProtoContract]
    public class DummyWrapper<T> : DummyWrapper {
        [ProtoMember(1)]
        public T[] TheData {get;set;}
    
        public override Type ElementType {get { return typeof(T); } }
    }
    

    with:

    [ProtoMember(1)]
    public DummyWrapper TheData {get;set;}
    

    would work, I suspect (untested). With classes, there is a little extra room that protobuf-net can use to implement inheritance (which also, technically, isn’t supported in the protobuf specification – this is a shim that protobuf-net squeezes in).

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

Sidebar

Related Questions

I have an array list named newSymptomList which contains a list of Symptom id's
without dumping tones of code here is the symptom having a threads which all
I don't know exactly the cause of this symptom but here goes. In our
Somewhere upstream of me, something happened that looks like unicode mangling. One symptom is
My symptom is that I cannot use a proxy with HTTPS requests with LWP.
I'm designing a new system and finding that I am struggling with the structure
The bizarre symptom I'm seeing on this page (only when viewing with IE 6)
Edit: The below information was the symptom that led me to the following tests.
I've always been of the opinion that large switch statements are a symptom of
One of the many things that's been lacking from my scraper service that I

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.