请帮忙.从服务器反序列化数据时遇到错误,
来自命名空间''的顶级XML元素'Name'引用不同类型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 …Run Code Online (Sandbox Code Playgroud)