<extendeddata xmlns =“”>未被预料到

时间:2017-10-02 16:58:04

标签: c# xml xml-deserialization

我正在尝试反序列化我的对象ExtendedData

<ExtendedData xmlns:SMseeder="http://seedmaster.ca/"><Static><SMseeder:FanSpeed>200</SMseeder:FanSpeed></Static><Dynamic><SMseeder:Bin1SeedRate>100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100</SMseeder:Bin1SeedRate><SMseeder:Bin2SeedRate>200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200</SMseeder:Bin2SeedRate><SMseeder:Bin3SeedRate>300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300</SMseeder:Bin3SeedRate><SMseeder:Bin4SeedRate>400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400</SMseeder:Bin4SeedRate><SMseeder:OpenersPackingPressure>500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500</SMseeder:OpenersPackingPressure></Dynamic></ExtendedData>

但我得到的错误是在搜索之后没有预料到我的课程改变了一点但仍然是同样的问题

 [XmlType(Namespace = "http://seedmaster.ca/", TypeName = "SMseeder")]
[XmlRoot(ElementName = "ExtendedData", Namespace = "http://seedmaster.ca/", IsNullable = false)]
public class ExtendedData
{
    [XmlElement("Static")]
    public ParamConfig StaticData { get; set; }
    [XmlElement("Dynamic")]
    public SeedPlanWayPoint PlanWayPoint { get; set; }
}

 [XmlRoot("Static")]
public class ParamConfig : Seeder.Common.IParamConfig
{
    #region Variables
    private ILog _logger;

    [XmlElement("SMseeder:FanSpeed")]
    UInt16 _auto_fan1_rpm;              

}

[XmlRoot("Dynamic")]
public class SeedPlanWayPoint
{
    [XmlElement("SMseeder:Bin1SeedRate")]
    public float Bin1SeedRate { get; set; }
    [XmlElement("SMseeder:Bin2SeedRate")]
    public float Bin2SeedRate { get; set; }
    [XmlElement("SMseeder:Bin3SeedRate")]
    public float Bin3SeedRate { get; set; }
    [XmlElement("SMseeder:Bin4SeedRate")]
    public float Bin4SeedRate { get; set; }

    [XmlElement("SMseeder:OpenersPackingPressure")]
    public float OpenersPackingPressure { get; set; }

    public SeedPlanWayPoint() { }
}

1 个答案:

答案 0 :(得分:1)

名称空间应该像这样声明

template<class T>
struct nullable_opt:std::optional<T> {
  using std::optional<T>::optional;
  nullable_opt( nullable_opt const& ) = default;
  nullable_opt( nullable_opt && ) = default;
  nullable_opt& operator=( nullable_opt const& ) = default;
  nullable_opt& operator=( nullable_opt && ) = default;
  nullable_opt() = default;

  nullable_opt(std::nullptr_t) {}
};