【发布时间】:2021-03-17 06:05:45
【问题描述】:
我正在尝试在 linux 中编译一些 c# 代码,我可以在 Windows 中使用 Visual Studio 命令行中的 csc 命令编译相同的代码。我也已经安装了mono-devel。
这是确切的错误:
mycode.cs(8,22): error CS0234: The type or namespace name `Forms' does not exist in the namespace `System.Windows'. Are you missing `System.Windows.Forms' assembly reference?
mycode.cs(70,27): error CS0246: The type or namespace name `Form' could not be found. Are you missing an assembly reference?
为什么会发生这种情况以及如何解决?
这是我在 linux 中用来编译它的命令:
mcs mycode.cs
在代码中,Windows 窗体已经包含在内:
using System.Windows.Forms;
简单的 hello world 代码也可以毫无错误地编译,我基本上遵循了这篇关于如何在 linux 中编译 c# 代码来设置所有内容的博文:
【问题讨论】:
-
.net 的哪个版本?我认为直到 .net core 3.1 之后,新的 .net 才引入桌面表单(您可以在线查看)
-
@ADyson 我不确定,我只按照这里的建议在 linux 中安装了 mono-devel:jonsson.xyz/2016/11/23/csharp-linux。代码也是给我的,不是我写的,不过代码没那么复杂,也就300-400行代码吧。
-
@ADyson 也可以编译简单的 hello world 代码而没有任何错误
-
什么是 Turbo C#? ._.
-
您关注的博客文章显示了一个简单的控制台应用程序,因此不能证明您可以在那里使用 WinForms。不要浪费时间,坚持使用 Windows。
标签: c# linux compiler-errors mono