简体   繁体   English

类型'X'和X'都使用来自命名空间''的XML类型名称'X'。 使用XML属性为类型指定唯一的XML名称和/或命名空间

[英]Types 'X' and X' both use the XML type name, 'X', from namespace ''. Use XML attributes to specify a unique XML name and/or namespace for the type

I am receiving the below exception when deserializing one of my DTO's, is there ANY way around this without having to use IXmlSerializable? 在反序列化我的一个DTO时,我收到以下异常,是否有任何解决方法而不必使用IXmlSerializable?

"Types 'RRA.Core.Services.DataContracts.ReferenceData.Status' and 'RRA.Core.Services.DataContracts.AR.Status' both use the XML type name, 'Status', from namespace ''. Use XML attributes to specify a unique XML name and/or namespace for the type." “类型'RRA.Core.Services.DataContracts.ReferenceData.Status'和'RRA.Core.Services.DataContracts.AR.Status'都使用来自命名空间''的XML类型名称'Status'。使用XML属性指定该类型的唯一XML名称和/或命名空间。“

Here is the DTO: 这是DTO:

namespace RRA.Core.Services.DataContracts.AR
{
    using System.Runtime.Serialization;

    /// <summary>
    /// Status data object
    /// </summary>
    [DataContract]
    public class Status : RRA.Core.Services.DataContracts.ReferenceData.Status
    {
    }
}

****UPDATE/SOLUTION**** **** UPDATE /溶液****

This fixed the particular issue I was having. 解决了我遇到的特殊问题。

Your two classes have the exact same name. 您的两个类具有完全相同的名称。 In C# that's okay, because they're in different namespaces - one is in RRA.Core.Services.DataContracts.AR and one is in RRA.Core.Services.DataContracts.ReferenceData. 在C#中没问题,因为它们位于不同的名称空间中 - 一个位于RRA.Core.Services.DataContracts.AR中,一个位于RRA.Core.Services.DataContracts.ReferenceData中。 You need to do the same thing for your XML. 您需要为XML执行相同的操作。

On both Status classes, set the Namespace and Name properties of the DataContract attribute to differentiate between them. 在两个Status类上,设置DataContract属性的Namespace和Name属性以区分它们。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何解决“都使用 XML 类型名称 X,使用 XML 属性为类型指定唯一的 XML 名称和/或命名空间”? - How to solve “Both use the XML type name X, use XML attributes to specify a unique XML name and/or namespace for the type”? DataTypes XSD两个WSDL文件-类型&#39;X&#39;和X&#39;都使用来自名称空间的XML类型名称&#39;X&#39; - DataTypes XSD two WSDL files - Types 'X' and X' both use the XML type name, 'X', from namespace '' XML序列化错误:2种类型都使用XML类型名称“关系”,来自命名空间&#39;&#39; - XML Serialization error: 2 types both use the XML type name, 'Relationship', from namespace '' 找不到类型或名称空间名称X - The type or namespace name X could not be found 找不到类型或名称空间名称“ X” - The type or namespace name 'X' could not be found 如何使用XML属性指定另一个XML名称? - How I can use XML attributes to specify another XML name? 将XPath与XML名称空间一起使用 - Use XPath with XML namespace 结合使用LINQ XML和名称空间 - Use LINQ XML with a namespace 将解决方案从MVC 3.x升级到MVC 5.2.3:类型或名称空间名称“ Mvc”在名称空间“ System.Web”中不存在 - Upgrading solution from MVC 3.x to MVC 5.2.3: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' 命名空间“Y”中不存在类型或命名空间名称“X” - 在 VS 生成的代码中 - The type or namespace name 'X' does not exist in the namespace 'Y' - in VS generated code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM