Type Reason ArgumentException XmlTextWriter.Namespaces is false for the writer, and prefix and ns are not both null or string.Empty. InvalidOperationException The XmlTextWriter.WriteState is not one of the following: WriteState.Attribute or WriteState.Element.
In the dnprdnext release, the recommended practice is to create System.Xml.XmlWriter instances using the erload:System.Xml.XmlWriter.Create method and the System.Xml.XmlWriterSettings class. This allows you to take full advantage of all the new features introduced in this release. For more information, see Creating XML Writers.
This is a more advanced version of XmlWriter.WriteAttributeString(string, string, string) that allows you to write an attribute value using multiple write methods, such as XmlTextWriter.WriteString(string).