請幫助。我同時從服務器反序列化的數據得到一個錯誤,名稱空間中名爲'name'的XML元素引用不同類型
頂部的XML元素「名稱」從命名空間「」涉及不同類型的 Object1.LocalStrings和System.String。使用XML屬性爲該元素指定另一個XML名稱或命名空間。
我有一個ObjectType類,它包含屬性Name和List<SupportedIp>
。 SupportedIp類還包含屬性Name。請參考下面我的代碼:
[XmlRootAttribute("SupportedIp", Namespace = "http://test.com/2010/test", IsNullable = false)]
public partial class SupportedIp
{[XmlElementAttribute(Namespace = "")]
public string Name
{
get;
set;
} .... }
[GeneratedCodeAttribute("xsd", "2.0.50727.1432")]
[SerializableAttribute()]
[DebuggerStepThroughAttribute()]
[DesignerCategoryAttribute("code")]
[XmlTypeAttribute(Namespace = "http://test.com/2010/test")]
[XmlRootAttribute("ObjectType", Namespace = "http://test.com/2010/test", IsNullable = false)]
public partial class ObjectType
{
/// <remarks/>
[XmlElementAttribute(ElementName = "", Namespace = "")]
public LocalStrings Name
{
get;
set;
}
/// <remarks/>
[XmlArrayAttribute(ElementName = "Supportedip", Namespace = "")]
[XmlArrayItemAttribute(IsNullable = false, Namespace = "")]
public List<Supportedip> Supportedip
{
get;
set;
}
}
當應用達到XmlSerializer的部分,顯示錯誤。我見過有些相關的帖子,但沒有答案。