由于名称空间名称不存在而导致的 Mono 编译错误

Mono compile error due to namespace name does not exists

我在 macOS 上使用单声道并尝试编译此 C# 代码:https://gist.github.com/bneg/bf8c05664324e3efeb1fb05902152a20

使用以下命令:

mcs Program.cs

它产生以下错误:

Program.cs(4,14): error CS0234: The type or namespace name `Management' does not exist in the namespace `System'. Are you missing an assembly reference?
Program.cs(5,14): error CS0234: The type or namespace name `Management' does not exist in the namespace `System'. Are you missing an assembly reference?

我也尝试过以下命令:

mcs -pkg:dotnet Program.cs

我收到这个错误:

Program.cs(17,25): error CS0234: The type or namespace name `Automation' does not exist in the namespace `System.Management'. Are you missing an assembly reference?
Program.cs(18,25): error CS0234: The type or namespace name `Automation' does not exist in the namespace `System.Management'. Are you missing an assembly reference?

为了编译它应该做哪些修改?

我不确定你是否可以 运行 通过 mac os.

上的单声道那样的 powershell

您至少需要引用如下内容: https://www.nuget.org/packages/System.Management.Automation

但是,如果您没有安装 powershell,则不能保证它能正常工作。由于 linux(原文如此!)上的 powershell 可以 only run on .net core,很可能您无法实现您想要完成的目标。