相关疑难解决方法(0)

名称空间中名为"name"的XML元素引用不同的类型

请帮忙.从服务器反序列化数据时遇到错误,

来自命名空间''的顶级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)

xml namespaces xml-serialization c#-4.0

9
推荐指数
1
解决办法
1万
查看次数

标签 统计

c#-4.0 ×1

namespaces ×1

xml ×1

xml-serialization ×1