简体   繁体   English

无法加载文件或程序集“System.Management.Automation,版本 = 3.0.0.0

[英]Could not load file or assembly 'System.Management.Automation, Version=3.0.0.0

I am building a application in C#, so far all it does is call the "get-process" powershell command.我正在用 C# 构建一个应用程序,到目前为止它所做的只是调用“get-process”powershell 命令。

I have edited the csproj file to include System.Management.Automation我已经编辑了 csproj 文件以包含 System.Management.Automation

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

When run locally (Windows 8.1 running Powershell version 4) it works.在本地运行时(运行 Powershell 版本 4 的 Windows 8.1)它可以工作。

When run on a remote Windows 7 machine with Powershell version 2, the program throws an exception在装有 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.

It cannot find System.Management.Automation Version=3.0.0.0.它找不到 System.Management.Automation Version=3.0.0.0。 I was lead to believe that this would work on any version of Powershell and reference the local version我相信这适用于任何版本的 Powershell 并引用本地版本

The cmdlet Get-Process does work on PS V2. cmdlet Get-Process 确实适用于 PS V2。

Is it possible to stop forcing version 3 of system management automation?是否可以停止强制使用系统管理自动化的第 3 版? I've read you can do this in the app.config but there is no reference to system management automation.我读过您可以在 app.config 中执行此操作,但没有提及系统管理自动化。

Thankyou for your time.感谢您的时间。

------------------------------------------------------ EDIT ----------------------------------------------- -------------------------------------------------- - - 编辑 - - - - - - - - - - - - - - - - - - - - - - - ——

I was able to make this work but setting the Target framework to .Net 3.5, however this now forces PS V2.我能够完成这项工作,但将目标框架设置为 .Net 3.5,但是这现在强制 PS V2。 Is there anyway I can target the local version of the system management dll and make clients use that version?无论如何我可以定位系统管理dll的本地版本并使客户端使用该版本吗?

Powershell 2.0 does not include System.Management.Automation V3. Powershell 2.0 不包括 System.Management.Automation V3。 System.Management.Automation is provided by Windows Management Framework Core, not .Net. System.Management.Automation 由 Windows Management Framework Core 提供,而不是 .Net。 If you've got Powershell 2.0, you do not have Automation 3.0.如果你有 Powershell 2.0,你就没有 Automation 3.0。 For a list of what files/assemblies are provided in Powershell 2.0 visit the following site:有关 Powershell 2.0 中提供的文件/程序集的列表,请访问以下站点:

Windows Management Framework (Windows PowerShell 2.0, WinRM 2.0, and BITS 4.0) Windows 管理框架(Windows PowerShell 2.0、WinRM 2.0 和 BITS 4.0)

Upgrade to Powershell 4.0 by installing WMF 4.0 from Microsoft on the target machine.通过在目标计算机上安装来自 Microsoft 的 WMF 4.0 升级到 Powershell 4.0。

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

I had this exact problem on a fully up to date Windows 10 system.我在完全最新的 Windows 10 系统上遇到了这个确切的问题。

What solved it for me was installing the latest release of Powershell from here:为我解决的是从这里安装最新版本的 Powershell:

https://github.com/powershell/powershell https://github.com/powershell/powershell

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 运行 Start-DSCConfiguration 时出错:无法加载文件或程序集“System.Management.Automation”,版本 = 7.1.0.0 - Error when running Start-DSCConfiguration: Could not load file or assembly 'System.Management.Automation', Version=7.1.0.0 运行 powershell 脚本时云不加载文件或程序集“System.Management.Automation” - Cloud not load file or assembly 'System.Management.Automation' while running powershell script 加载System.Management.Automation程序集时出错 - Error loading System.Management.Automation assembly 2.0版的System.Management.Automation? - 2.0 version of System.Management.Automation? 无法加载文件或程序集 'System.Web.WebPages.Razor,版本 = 3.0.0.0 - Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0 无法在“新”框中加载文件或程序集&#39;System.Web.Mvc,版本= 3.0.0.0 - Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0 on NEW box 运行时错误:无法加载文件或程序集“System.Web.WebPages.Razor,版本=3.0.0.0” - Runtime error: Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0 无法在服务器上加载文件或程序集&#39;System.Web.Mvc,Version = 3.0.0.0 - Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0 at server 无法加载文件或程序集“System.Web.Mvc,Version = 3.0.0.0”或其依赖项之一 - Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0' or one of its dependencies 无法加载文件或程序集“ Common.Logging,版本= 3.0.0.0” - Could not load file or assembly 'Common.Logging, Version=3.0.0.0'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM