簡體   English   中英

monodevelop編譯錯誤; 如果存在引用,為什么會丟失匯編引用?

[英]monodevelop compling error; why does misses assembly reference if those exists?

我從MonoDevelop創建了一個GTK#2.0項目,它生成了兩個文件:

Program.cs

using System;
using Gtk;

namespace Application
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            Application.Init();
            MainWindow win = new MainWindow();
            win.Show();
            Application.Run();
        }
    }
}

MainWindow.cs:

using System;
using Gtk;

public partial class MainWindow : Gtk.Window
{
    public MainWindow() : base(Gtk.WindowType.Toplevel)
    {
        Build();
    }

    protected void OnDeleteEvent(object sender, DeleteEventArgs a)
    {
        Application.Quit();
        a.RetVal = true;
    }
}

我按下了“調試”按鈕,未修改任何代碼。 然后編譯器打印此:

The type or namespace name `Init' does not exist in the namespace `Application'. Are you missing an assembly reference? (CS0234)
The type or namespace name `Run' does not exist in the namespace `Application'. Are you missing an assembly reference? (CS0234)
The type or namespace name `Quit' does not exist in the namespace `Application'. Are you missing an assembly reference? (CS0234)

我在“解決方案”選項卡上看到了“參考”列表,並且存在Gtk.Application.Init,Run,Quit。 那為什么會發生這個錯誤呢?

將Program.cs修改為:

using System;
using Gtk;

namespace Application
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            Gtk.Application.Init();
            MainWindow win = new MainWindow();
            win.Show();
            Gtk.Application.Run();
        }
    }
}

修改MainWindow.cs為:

using System;
using Gtk;

public partial class MainWindow : Gtk.Window
{
    public MainWindow() : base(Gtk.WindowType.Toplevel)
    {
        Build();
    }

    protected void OnDeleteEvent(object sender, DeleteEventArgs a)
    {
        Gtk.Application.Quit();
        a.RetVal = true;
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM