Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.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
没有Visual Studio的C#图形用户界面_C#_User Interface_Mono - Fatal编程技术网

没有Visual Studio的C#图形用户界面

没有Visual Studio的C#图形用户界面,c#,user-interface,mono,C#,User Interface,Mono,好吧,我是C语言的新手,但我需要创建一个简单的GUI,但我没有Visual Studio(我使用Geany和Mono) 问题是,当我尝试谷歌发现的以下代码时: using System; using System.Windows.Forms; using System.ComponentModel; using System.Drawing; public class FirstForm : Form { private Container components; private La

好吧,我是C语言的新手,但我需要创建一个简单的GUI,但我没有Visual Studio(我使用Geany和Mono)

问题是,当我尝试谷歌发现的以下代码时:

using System;
using System.Windows.Forms;
using System.ComponentModel;
using System.Drawing;

public class FirstForm : Form
{
  private Container components;
  private Label   howdyLabel;

  public FirstForm()
  {
    InitializeComponent();
  }

  private void InitializeComponent()
  {
    components = new Container ();
    howdyLabel = new Label ();

    howdyLabel.Location = new Point (12, 116);
    howdyLabel.Text   = "Howdy, Partner!";
    howdyLabel.Size   = new Size (267, 40);
    howdyLabel.AutoSize = true;
    howdyLabel.Font   = new Font (
      "Microsoft Sans Serif", 
      26, System.
      Drawing.FontStyle.Bold);
    howdyLabel.TabIndex = 0;
    howdyLabel.Anchor  = AnchorStyles.None;
    howdyLabel.TextAlign = ContentAlignment.MiddleCenter;

    Text = "First Form";
    Controls.Add (howdyLabel);
  }

  public static void Main()
  {
    Application.Run(new FirstForm());
  }
}
我在尝试编译时遇到以下错误:

C:\C#\test2.cs(2,14): error CS0234: The type or namespace name 'Windows' does not exist in the namespace 'System'. Are you missing an assembly reference?
C:\C#\test2.cs(4,14): error CS0234: The type or namespace name 'Drawing' does not exist in the namespace 'System'. Are you missing an assembly reference?
C:\C#\test2.cs(9,11): error CS0234: The type or namespace name 'Label' could not be found. Are you missing a using directive or an assembly reference?
Compilation failed: 3 error(s), 0 warnings
我下载了两个DLL,但我不知道下一步该怎么做。
链接到代码:

您正在使用Microsoft WinForms UI库,Mono不包括该库

您需要使用一个,例如GTK。

您也可以使用。

如果您在mono上使用WinForm,可能最好使用GTK,但是如果您想在mono上使用WinForms,这是可能的。有关更多信息,请参阅文档

您必须以这种方式使用
gmcs
来编译您的程序:

gmcs Program.cs -r:System.Windows.Forms.dll

Visual Basic与此无关。@Snackers我们是指Visual Studio吗?您不使用Visual Studio有什么原因吗?Visual Studio Express是免费的。可能是因为他在Linux上,并且他想在Linux上运行他的程序;)@aleroot我只是想确保他知道,如果他在Windows for Windows上开发,有一个免费的解决方案可以解决他的所有问题。:)