I am trying to dispose XmlWriter object:
try { [System.Xml.XmlWriter] $writer = [System.Xml.XmlWriter]::Create('c:\some.xml') } finally { $writer.Dispose() }
Error:
Method invocation failed because [System.Xml.XmlWellFormedWriter] doesn’t contain a method named ‘Dispose’.
On the other side:
$writer -is [IDisposable] # True
What should I do?
Dispose is protected on
System.Xml.XmlWriter. You should useCloseinstead.