我正在用C#构建一个应用程序,到目前为止它只是调用"get-process"powershell命令.
我编辑了csproj文件以包含System.Management.Automation
<ItemGroup>
<Reference Include="System.Management.Automation" />
Run Code Online (Sandbox Code Playgroud)
在本地运行时(Windows 8.1运行Powershell版本4)它可以工作.
在具有Powershell版本2的远程Windows 7计算机上运行时,该程序将引发异常
System.IO.FileNotFoundException: Could not load file or assembly 'System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Run Code Online (Sandbox Code Playgroud)
它找不到System.Management.Automation Version = 3.0.0.0.我一直认为这适用于任何版本的Powershell并引用本地版本
cmdlet Get-Process适用于PS V2.
是否有可能停止强制执行系统管理自动化的第3版?我已经读过您可以在app.config中执行此操作,但没有参考系统管理自动化.
感谢您的时间.
-------------------------------------------------- ----编辑--------------------------------------------- -
我能够完成这项工作,但将Target框架设置为.Net 3.5,但是这会强制PS V2.反正我是否可以定位系统管理dll的本地版本并使客户端使用该版本?