Possible Duplicate:
Serializing object with no namespaces using DataContractSerializer
When I'm serializing object of this class:
[DataContract]
internal class Settings
{
[DataMember]
public List<string> AllowedEmails { get; set; }
}
I've got this XML as output:
<?xml version="1.0" encoding="utf-8"?>
<Settings xmlns="http://schemas.datacontract.org/2004/07/Commands.Settings">
<AllowedEmails xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d2p1:string>asdsada</d2p1:string>
<d2p1:string>asdsada</d2p1:string>
</AllowedEmails>
</Settings>
Is there a way to get rid of namespaces xmlns="http://schemas.datacontract.org/2004/07/Commands.Settings"
and xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"
?
I know I can remove d2p1 namespace by doing this:
public Settings()
{
[DataMember]
public AllowedEmails AllowedEmails { get; set; }
}
[CollectionDataContract]
public class AllowedEmails : List<string>
{
public AllowedEmails()
{
}
}
But may be there is more elegant solution?