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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:02:50+00:00 2026-05-28T05:02:50+00:00

When I serialize the following class, the ContentPageId XML element is missing from the

  • 0

When I serialize the following class, the ContentPageId XML element is missing from the resulting XML file.

[CollectionDataContract(ItemName = "Widget")]
public sealed class StructurePage : List<Widget>, IEquatable<StructurePage>
{
    [DataMember]
    public int ContentPageId
    {
        get;
        set;
    }

    public StructurePage(){}

    public StructurePage(int pageId)
    {
        this.ContentPageId = pageId;
    }

    public bool Equals(StructurePage other)
    {
        return this.ContentPageId.Equals(other.ContentPageId);
    }
}
  1. Why is the property skipped when serializing and how to include it as XML element?
  2. Is it possible to include it in serialization as an XML attribute to the StructurePage element? Was looking for this around the net but could find any info on it, apparently with XmlSerializer there was XmlAttributeAttribute attribute but no such thing with DataContractSerializer.
  • 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-28T05:02:51+00:00Added an answer on May 28, 2026 at 5:02 am

    Go through this post http://social.msdn.microsoft.com/Forums/eu/wcf/thread/57eb195a-43a9-47fe-8b1a-a9d23feb2df2

    According to this

    Collection data contract classes cannot contain extra data members.

    Hope this helps.

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

Sidebar

Related Questions

I have the following class that I want to serialize to an XML file
How can I XML-serialize the following property: public class SomeCollection { [Xml???] public SomeClass
I'm trying to serialize the following class: [Serializable()] public class BindingNode : IEnumerable<BindingNode> {
I have an xml file.i need to serialize to c# class. <Configs> <Services> <Path>
I am trying to serialize an xml to a class with the following way:
i am trying to XML serialize a class object but having the following problem:
My application has the following classes: public class Widget { public virtual int Id
Let's say I have the following class structure (simplified from my real-world problem): Public
I'm trying to figure out how to serialize the following class into XML (in
Given the following class structure, will Bar serialize/deserialize as expected? public class Foo {

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.