【发布时间】:2011-04-05 21:47:50
【问题描述】:
我正在编写一个可以运行我希望在应用程序线程上运行的 PowerShell 脚本的应用程序。以下代码:
Runspace runspace = RunspaceFactory.CreateRunspace(); // create Powershell runspace
runspace.ThreadOptions = PSThreadOptions.UseCurrentThread;
在 Windows 7 上可以正常工作和编译,但由于以下错误而无法在 XP 中编译:
'System.Management.Automation.Runspaces.Runspace' does not contain a definition for
'ThreadOptions' and no extension method 'ThreadOptions' accepting a first argument of type
'System.Management.Automation.Runspaces.Runspace' could be found (are you missing a using
directive or an assembly reference?)
The name 'PSThreadOptions' does not exist in the current context
这个问题是否与 powershell v1 vs v2 有关?我在 XP 机器(和 VS 2010)上安装了 .NET 4。谢谢!
【问题讨论】:
标签: c# powershell automation