2
我正在編寫一個可以運行PowerShell腳本的應用程序,我希望在應用程序的線程上運行這些腳本。下面的代碼:在XP上運行此C#代碼時遇到問題
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 V2 VS有關?我在XP機器上安裝了.NET 4(和VS 2010)。謝謝!
謝謝!現在看看我是否可以找出解決方法...... :) – Evan 2010-08-30 18:51:01
您可以通過Microsoft的Microsoft Management Framework for XP(http://support.microsoft.com/kb/968929)安裝PowerShell 2.0嗎?請注意,這與.NET 4沒有任何關係。 – 2010-08-30 19:34:16
@Keith,非常感謝 - 使上述代碼生效! – Evan 2010-08-30 19:49:01