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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:11:58+00:00 2026-05-23T17:11:58+00:00

I have a custom List which carries some attributes I need to serialize along

  • 0

I have a custom List which carries some attributes I need to serialize along with its containing items.

However, as soon as I add a ProtoContract attribute to my custom list, its items dont get serialized anymore.

Example:

    [ProtoContract]
    public class MyCollection : List<string> { 

    [ProtoMember(1)]
    public string MyAdditionalField;
   }

Is this not supposed to work out of the box?

The only possible workaround I can think of is using a surrogate for the custom list which contains a separate List which then contains all the data. However, we are dealing with quite a lot of custom Lists… so this would be an inefficient approach.

Thank you,
TH

  • 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-23T17:11:59+00:00Added an answer on May 23, 2026 at 5:11 pm

    In common with XmlSerializer and TypeDescriptor (and possibly DataContractSerializer – I haven’t checked), there is a strong divide between is a list vs contains a list. If something is a list, it doesn’t have values itself.

    The preferred layout there would be to either have a list or values.

    At the protocol level, there is simply no way of representing that, as this is just repeated string {name} = {field} – there is simply nowhere for MyAdditionalField to go.

    (update); tested, and indeed XmlSerializer behaves the same:

    <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="
    http://www.w3.org/2001/XMLSchema">
      <string>abc</string>
      <string>def</string>
    </ArrayOfString>
    

    DataContractSerializer hated it more, throwing:

    Type ‘MyCollection’ is an invalid collection type since it has DataContractAttribute attribute.

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

Sidebar

Related Questions

I have the below code, which iterates over a list based on a custom
I have created a custom list as a feature in sharepoint. i need to
I have defined a custom Sharepoint list for special attributes related to a software
I have implemented a custom list view which looks like the twitter timeline. adapter
I have a custom list which can contain a CustomContentType. This is how i
I can't find solution for the following problem. I have custom list field, which
Overview: I have an Expandable List View which displays items of the type ToDoElement
I have a custom list which I want to embed as a resource so
I have made a custom list in which I am getting all the phone
I have custom List which has image field. I have to display the image

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.