【问题标题】:Having trouble running this C# code on XP在 XP 上运行此 C# 代码时遇到问题
【发布时间】: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


    【解决方案1】:

    来自here

    “此属性是在 Windows PowerShell 2.0 中引入的。”

    【讨论】:

    猜你喜欢
    • 2022-07-12
    • 1970-01-01
    • 1970-01-01
    • 2021-01-01
    • 1970-01-01
    • 2023-03-13
    • 2022-06-30
    • 2020-02-23
    • 2018-11-04
    相关资源
    最近更新 更多