Reference to System.Management for Powershell on C# .NET 4.0 not working

Viewed 7851

I have a .NET 4.0 C# project where I need to run Powershell via C# in powershell runspace. I had tested my code it was all working good.

When opening same project on a new computer (Win10, VS2017) and trying to run same project getting issues. I have referenced the DLL on:

C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Management.Automation\v4.0_3.0.0.0__31bf3856ad364e35\System.Management.Automation.dll

Also doing this using commands

using System.Management;
using System.Management.Automation;
using System.Management.Automation.Runspaces;

but System.Management.Automation and System.Management.Automation.Runspaces are not recognized.

Getting the error: The type or namespace name 'Automation' does not exist in the namespace 'System.Management' (are you missing an assembly reference?)

Somehow the references are not being used...

1 Answers
Related