When overridden in a derived class, writes out the namespace-qualified name. This method looks up the prefix that is in scope for the given namespace.
Type Reason ArgumentException localName is null, is string.Empty, or is not a valid XML name. InvalidOperationException The XmlWriter.WriteState is WriteState.Closed. System.Xml.XmlException localName is not a valid XML name.
If ns maps to the current default namespace, no prefix is generated.
When writing attribute values, this method generates a prefix if ns is not found. When writing element content, it throws an exception if ns is not found.
If a class derived from the System.Xml.XmlWriter does not override this method localName is not checked to be a valid W3C XML name. In such case, before calling this method, the validity of the string can be checked by XmlReader.IsName(string) method.
For the asynchronous version of this method, see XmlWriter.WriteQualifiedNameAsync(string, string).