我试图处理XmlWriter对象:
try
{
[System.Xml.XmlWriter] $writer = [System.Xml.XmlWriter]::Create('c:\some.xml')
}
finally
{
$writer.Dispose()
}
错误:
Method invocation Failed because
[System.Xml.XmlWellFormedWriter]
doesn’t contain a method named
‘Dispose’.
另一方面:
$writer -is [IDisposable]
# True
我该怎么办?
Dispose是System.Xml.XmlWriter上的
protected.你应该使用
关闭.
$writer.Close