When calling the method GetXml the class member _xmlw is created inside of an
using block. This causes the XmlWriter to be disposed when the block finishes and the locally stored variable is thus useless.
Change so that there is no local variable in the class for the XmlWriter and use the functionality in C# correctly.
using (_xmlw = XmlWriter.Create(xmlOutput, xmlSettings))
{
// Omited for clarity.
}
_xmlw.Something(); <--- The variable is disposed here and most likely throws an Exception if being called upon.
When calling the method GetXml the class member _xmlw is created inside of an using block. This causes the XmlWriter to be disposed when the block finishes and the locally stored variable is thus useless.
Change so that there is no local variable in the class for the XmlWriter and use the functionality in C# correctly.