O elemento XML chamado 'nome' do namespace faz referência a tipos distintos
Por favor ajude. Eu recebi um erro ao desserializar os dados do servidor,
O elemento XML principal 'Nome' do namespace '' faz referência aos tipos distintos Object1.LocalStrings e System.String. Use atributos XML para especificar outro nome XML ou namespace para o elemento ou tipos.
Eu tenho uma classe ObjectType que contém propriedades Name eList<SupportedIp>
. A classe SupportedIp contém a propriedade Name também. Por favor, consulte o meu código abaixo:
<code>[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; } } </code>
Quando a aplicação chega aXmlSerializer parte, exibe o erro. Eu já vi um post relacionado, mas não há uma resposta concisa.