I have a following class definition
[XmlRoot(ElementName = \"person\",Namespace = \"MyNamespace\")] public class Perso
Try the following.
public void WriteXml(XmlWriter writer) { writer.WriteAttributeString("xmlns", "my", null, "MyNamespace"); writer.WriteElementString("firstName", FirstName); writer.WriteElementString("lastName", LastName); }