如何編譯 Mono Hello World?

如何編譯 Mono Hello World?

我有 Ubuntu 11.04 和這個單聲道:

Mono JIT compiler version 2.6.7 (Debian 2.6.7-5ubuntu3)
Copyright (C) 2002-2010 Novell, Inc and Contributors. www.mono-project.com
    TLS:           __thread
    GC:            Included Boehm (with typed GC and Parallel Mark)
    SIGSEGV:       altstack
    Notifications: epoll
    Architecture:  x86
    Disabled:      none

我正在嘗試運行這個:

using System;

public class HelloWorld
{
    static public void Main ()
    {
        Console.WriteLine ("Hello Mono World");
    }
}

我收到這些錯誤:

ThinkPad-X201-Tablet:~/Desktop$ gmcs hello.cs
** (/usr/lib/mono/2.0/gmcs.exe:9128): WARNING **: Missing method .ctor in assembly /usr/lib/mono/2.0/gmcs.exe, type System.Runtime.CompilerServices.CompilerGeneratedAttribute
** (/usr/lib/mono/2.0/gmcs.exe:9128): WARNING **: The class System.Runtime.CompilerServices.CompilerGeneratedAttribute could not be loaded, used in gmcs
** (/usr/lib/mono/2.0/gmcs.exe:9128): WARNING **: Can't find custom attr constructor image: /usr/lib/mono/2.0/gmcs.exe mtoken: 0x0a0003d2
** (/usr/lib/mono/2.0/gmcs.exe:9128): WARNING **: Missing method .ctor in assembly /usr/lib/mono/2.0/gmcs.exe, type System.Runtime.CompilerServices.CompilerGeneratedAttribute
** (/usr/lib/mono/2.0/gmcs.exe:9128): WARNING **: Can't find custom attr constructor image: /usr/lib/mono/2.0/gmcs.exe mtoken: 0x0a0003d2
** (/usr/lib/mono/2.0/gmcs.exe:9128): WARNING **: Missing method .ctor in assembly /usr/lib/mono/2.0/gmcs.exe, type System.Runtime.CompilerServices.CompilerGeneratedAttribute
** (/usr/lib/mono/2.0/gmcs.exe:9128): WARNING **: Can't find custom attr constructor image: /usr/lib/mono/2.0/gmcs.exe mtoken: 0x0a0003d2
** (/usr/lib/mono/2.0/gmcs.exe:9128): WARNING **: Missing method .ctor in assembly /usr/lib/mono/2.0/gmcs.exe, type System.Runtime.CompilerServices.CompilerGeneratedAttribute
** (/usr/lib/mono/2.0/gmcs.exe:9128): WARNING **: Can't find custom attr constructor image: /usr/lib/mono/2.0/gmcs.exe mtoken: 0x0a0003d2
** (/usr/lib/mono/2.0/gmcs.exe:9128): WARNING **: Missing method .ctor in assembly /usr/lib/mono/2.0/gmcs.exe, type System.Runtime.CompilerServices.CompilerGeneratedAttribute
** (/usr/lib/mono/2.0/gmcs.exe:9128): WARNING **: Can't find custom attr constructor image: /usr/lib/mono/2.0/gmcs.exe mtoken: 0x0a0003d2
** (/usr/lib/mono/2.0/gmcs.exe:9128): WARNING **: Missing method .ctor in assembly /usr/lib/mono/2.0/gmcs.exe, type System.Runtime.CompilerServices.CompilerGeneratedAttribute
** (/usr/lib/mono/2.0/gmcs.exe:9128): WARNING **: Can't find custom attr constructor image: /usr/lib/mono/2.0/gmcs.exe mtoken: 0x0a0003d2
** (/usr/lib/mono/2.0/gmcs.exe:9128): WARNING **: Missing method .ctor in assembly /usr/lib/mono/2.0/gmcs.exe, type System.Runtime.CompilerServices.CompilerGeneratedAttribute
** (/usr/lib/mono/2.0/gmcs.exe:9128): WARNING **: Can't find custom attr constructor image: /usr/lib/mono/2.0/gmcs.exe mtoken: 0x0a0003d2
Unhandled Exception: System.TypeLoadException: A type load exception has occurred.

有任何想法嗎?

答案1

在我的設定上可以完美編譯。

您應該安裝此軟體包:

  • mono-2.0-開發

這應該繪製命令列編譯所需的所有依賴項。如果您想要更舒適,我建議安裝 monodevelop 軟體包。

相關內容