[英]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 /溶液****
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.