I'm writing an application that can run PowerShell scripts which I'd like to be run on the application's thread. The following code:
Runspace runspace = RunspaceFactory.CreateRunspace(); // create Powershell runspace
runspace.ThreadOptions = PSThreadOptions.UseCurrentThread;
Works and compiles fine on Windows 7, but can't be compiled in XP due to these errors:
'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
Is this issue related to powershell v1 vs v2? I have the .NET 4 install on the XP machines (and VS 2010). Thanks!