好的,我是 C# 新手,但我需要创建一个简单的 GUI,但我没有 Visual Studio(我使用 Geany 和 Mono)。
问题是,当我尝试通过 Google 找到以下代码时:
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,但我不知道下一步该做什么。
代码链接:http://www.informit.com/articles/article.aspx?p=27316 http://www.informit.com/articles/article.aspx?p=27316
您正在使用 Microsoft WinForms UI 库,Mono 不包含该库。
你需要使用一个Mono 兼容的 UI 库 http://www.mono-project.com/Gui_Toolkits,例如 GTK#。
您还可以使用WinForms 的 Mono 端口 http://www.mono-project.com/WinForms.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)