相关疑难解决方法(0)

如何使用.NET 4运行时运行PowerShell?

我正在更新管理某些.NET程序集的PowerShell脚本.该脚本是针对针对.NET 2构建的程序集(与PowerShell运行的框架的相同版本)编写的,但现在需要使用.NET 4程序集以及.NET 2程序集.

由于.NET 4支持运行针对旧版本框架构建的应用程序,因此最简单的解决方案是在需要针对.NET 4程序集运行时,使用.NET 4运行时启动PowerShell.

如何使用.NET 4运行时运行PowerShell?

.net powershell .net-4.0

232
推荐指数
10
解决办法
12万
查看次数

如何在PowerShell中配置System.Xml.XmlWriter

我正在尝试处置XmlWriter对象:

try
{
    [System.Xml.XmlWriter] $writer = [System.Xml.XmlWriter]::Create('c:\some.xml')
}
finally
{
    $writer.Dispose()
}
Run Code Online (Sandbox Code Playgroud)

错误:

方法调用失败,因为[System.Xml.XmlWellFormedWriter]不包含名为"Dispose"的方法.

另一方面:

 $writer -is [IDisposable]
 # True
Run Code Online (Sandbox Code Playgroud)

我该怎么办?

powershell dispose idisposable

10
推荐指数
2
解决办法
3988
查看次数

标签 统计

powershell ×2

.net ×1

.net-4.0 ×1

dispose ×1

idisposable ×1