【问题标题】:Using powershell with c# namespace error使用带有 c# 命名空间错误的 powershell
【发布时间】:2017-09-27 13:17:07
【问题描述】:

我正在尝试使用 c# 中的(远程)powershell。

我用:

using System.Management.Automation;
using System.Management.Automation.Runspace;

但是当我尝试构建我的应用程序时,我遇到了错误 CS0234(名称在命名空间中不存在)。我添加了 System.Management 的引用。

哪种编译方式?

Ps:我找到了一个帖子,他们说要添加 C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0 作为参考,但我没有这条路径...

PPs : Powershell 已完全安装在我的计算机上。

PPPs : 使用 win10 64 位

【问题讨论】:

  • 你搜索过那个目录吗?又名 windowspowershell\1.0
  • 添加引用并浏览...转到该路径(可以是 3.0 或 1.0)并选择 System.Management.Automation.dll
  • 顺便说一句,对于 64 位 win7,该路径似乎是正确的 ...

标签: c# powershell .net-assembly


【解决方案1】:

经过搜索和搜索,我终于在我的机器上找到了这个文件:

C:\windows\assembly\GAC_MSIL\System.Management.Automation\1.0.0.0__31bf3856ad364e35\System.Management.Automation.dll

哪个是参考。

【讨论】:

    【解决方案2】:

    【讨论】:

      【解决方案3】:

      运行空间是类。仅供参考:

      using System.Management.Automation;
      

      并添加参考:

      c:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Management.Automation\v4.0_3.0.0.0__31bf3856ad364e35\System.Management.Automation.dll

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-09-27
        • 1970-01-01
        • 2012-07-16
        • 1970-01-01
        • 2015-08-15
        • 1970-01-01
        • 2016-04-01
        相关资源
        最近更新 更多