1

I've generate a class with xsd.exe and it came out like this (a partial):

public partial class MyClass{       

    private SignatureType signatureField;

    [System.Xml.Serialization.XmlElementAttribute(Namespace = "http://www.w3.org/2000/09/xmldsig#")]
    public SignatureType Signature {
        get {
            return this.signatureField;
        }
        set {
            this.signatureField = value;
        }
    }    
}

I'm coding an Asp.Net 5 controller that outputs that object as an XML, the problem is that the seriarizer is using the private property's name instead of the public one ending up like this

<MyClass>
    <signatureField></signatureField>
</MyClass>

with the Field suffix.

What could be causing this?

thanks

Renato Herrera
  • 191
  • 1
  • 11
  • 1
    Can you please show code that either returns object or performs serialization? – Alexei Levenkov Mar 24 '16 at 21:02
  • 1
    This could conceivably happen if 1) You marked your class as `[Serializable]` and 2) You are actually using `DataContractSerializer` not `XmlSerializer`. You can check [Is there a way to make DataContractSerializer output cleaner XML?](https://stackoverflow.com/questions/1953984/is-there-a-way-to-make-datacontractserializer-output-cleaner-xml) for details. Likely you will need to provide a [complete examlple](https://stackoverflow.com/help/mcve) for us to help more. – dbc Mar 24 '16 at 22:00
  • Yes the class is marked as serializable, i will try without it. – Renato Herrera Mar 25 '16 at 03:42
  • The code that does the serialisation is .net mvc... The contoller returns an object and I'm asking for xml in the headers – Renato Herrera Mar 25 '16 at 03:44

1 Answers1

0

Removing the [Serializable] attribute did it for me.

thanks

Renato Herrera
  • 191
  • 1
  • 11