简体   繁体   中英

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?

"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."

Here is the 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****

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. You need to do the same thing for your XML.

On both Status classes, set the Namespace and Name properties of the DataContract attribute to differentiate between them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM