XmlSerializer - There was an error reflecting type

后端 未结 18 1627
借酒劲吻你
借酒劲吻你 2020-11-28 02:46

Using C# .NET 2.0, I have a composite data class that does have the [Serializable] attribute on it. I am creating an XMLSerializer class and passi

18条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-28 03:38

    I have a slightly different solution to all described here so far, so for any future civilisation here's mine!

    I had declared a datatype of "time" as the original type was a TimeSpan and subsequently changed to a String:

    [System.Xml.Serialization.XmlElementAttribute(DataType="time", Order=3)]
    

    however the actual type was a string

    public string TimeProperty {
        get {
            return this.timePropertyField;
        }
        set {
            this.timePropertyField = value;
            this.RaisePropertyChanged("TimeProperty");
        }
    }
    

    by removing the DateType property the Xml can be serialized

    [System.Xml.Serialization.XmlElementAttribute(Order=3)]
    public string TimeProperty {
        get {
            return this.timePropertyField;
        }
        set {
            this.timePropertyField = value;
            this.RaisePropertyChanged("TimeProperty");
        }
    }
    

提交回复
热议问题