Failed to load file or assembly "System.Management.Automation, Version = 3.0.0.0

I am building a C # application until all it does is call the powershell get-process command.

I edited the csproj file to include System.Management.Automation

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

When launched locally (Windows 8.1 runs Powershell version 4), it works.

When running on a remote Windows 7 machine with Powershell version 2, the program throws an exception

 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. 

Cannot find System.Management.Automation Version = 3.0.0.0. I am fortunate that this will work on any version of Powershell and reference the local version

The Get-Process cmdlet runs on PS V2.

Is it possible to stop forcing version 3 of system automation automation? I read that you can do this in app.config, but there is no link to automate system management.

Thank you for your time.

----------------------------------------------- --- ---- EDIT ------------------------------------------ --- -

I managed to do this work, but installing the Target platform on .Net 3.5, however now it forces PS V2. Anyway, can I target the local version of the system management dll and force clients to use this version?

+6
source share
1 answer

Powershell 2.0 does not include System.Management.Automation V3. System.Management.Automation is provided by the Windows Management Framework database, not .Net. If you have Powershell 2.0, you do not have Automation 3.0. For a list of files / assemblies in Powershell 2.0, visit the following site:

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

Upgrade Powershell 4.0 by installing WMF 4.0 from Microsoft on the target machine.

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

+7
source

Source: https://habr.com/ru/post/979749/


All Articles