'XML serializer wont write one of my attributes

I have a Problem with my XML-Serialization. I have the following XML class:

[System.SerializableAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)] public partial class Data {

    private int field1;

    private bool field2;

    private int field3;

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public int Field1
    {
        get
        {
            return this.field1;
        }
        set
        {
            this.field1= value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlIgnoreAttribute()]
    public bool Field2
    {
        get
        {
            return this.field2;
        }
        set
        {
            this.field2= value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public int Field3
    {
        get
        {
            return this.field3;
        }
        set
        {
            this.field3= value;
        }
    } }

But when i create my class and fill those fields, it only shows this in the XML:

<Data Field3="5"/>

so its not writing my Field1="1" (which i set in code) and i have no idea why. Field2 is not there cause of the XmlIgnoreAttibute, but Field1 does not have that.

(The XMLClass has been automatically generated with a xml file that is propperly filled. But its a huge file, so the only thing i can imagine is that there is a hidden setting somewhere)

I am at a loss of where to look for the reason that my Field1 won't be saved



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source