加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 无法加载文件或程序集’System.Management.Automation,Ver

发布时间:2020-12-15 08:36:38 所属栏目:百科 来源:网络整理
导读:我正在用C#构建一个应用程序,到目前为止它只是调用“get-process”power shell命令. 我编辑了csproj文件以包含System.Management.Automation ItemGroup Reference Include="System.Management.Automation" / 在本地运行时(Windows 8.1运行Powershell版本4)它
我正在用C#构建一个应用程序,到目前为止它只是调用“get-process”power shell命令.

我编辑了csproj文件以包含System.Management.Automation

<ItemGroup>
 <Reference Include="System.Management.Automation" />

在本地运行时(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.

它找不到System.Management.Automation Version = 3.0.0.0.我一直认为这适用于任何版本的Powershell并引用本地版本

cmdlet Get-Process适用于PS V2.

是否有可能停止强制执行系统管理自动化的第3版?我已经读过您可以在app.config中执行此操作,但没有参考系统管理自动化.

感谢您的时间.

————————————————– —-编辑——————————————— –

我能够完成这项工作,但将Target框架设置为.Net 3.5,但是这会强制PS V2.反正我是否可以定位系统管理dll的本地版本并使客户端使用该版本?

解决方法

Powershell 2.0不包括System.Management.Automation V3. System.Management.Automation由Windows Management Framework Core提供,而不是.Net.如果你有Powershell 2.0,你就没有Automation 3.0.有关Powershell 2.0中提供的文件/程序集的列表,请访问以下站点:

Windows Management Framework (Windows PowerShell 2.0,WinRM 2.0,and BITS 4.0)

通过在目标计算机上从Microsoft安装WMF 4.0升级到Powershell 4.0.

http://www.microsoft.com/en-us/download/details.aspx?id=40855

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读