Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
来自C#的Powershell脚本错误_C#_.net_Powershell - Fatal编程技术网

来自C#的Powershell脚本错误

来自C#的Powershell脚本错误,c#,.net,powershell,C#,.net,Powershell,我正在尝试从我的C#程序运行PowerShell脚本。在C#文件中,我做了一些事情,比如创建运行空间来设置所有内容。构建时,项目输出到cshtml网页。到目前为止,我添加到CS文件中的内容应该不会对网页产生任何影响 当我们构建时,网页弹出时会出现错误: FileNotFoundException:无法加载文件或程序集“System.Management.Automation,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e

我正在尝试从我的C#程序运行
PowerShell
脚本。在C#文件中,我做了一些事情,比如创建运行空间来设置所有内容。构建时,项目输出到
cshtml
网页。到目前为止,我添加到CS文件中的内容应该不会对网页产生任何影响

当我们构建时,网页弹出时会出现错误:

FileNotFoundException:无法加载文件或程序集“System.Management.Automation,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”。系统找不到指定的文件

即使我添加的唯一一行是:

Runspace runspace = RunspaceFactory.CreateRunspace();

我尝试添加
Nuget
软件包等,但运气不佳。

您正在运行哪个版本的powershell?正在运行powershell 4