This is a "note-to-self" type blogpost, but some other people might find it useful.
How to install the C# compiler on Ubuntu (Linux)? There are several possibilities.
The first: use Mono. This is an open-source version of Microsoft's .NET
framework.
Compiling things on the command line is simple, merely use gmcs
when calling the compiler.
There are some idiosyncrasies unique to Mono, however. For example, you'll need to install (for Ubuntu 12.04) the gtk-sharp2
package for GUI programming.
There are difficulties with this (I never got it to work!). Consider the following program:
/* begin hello.cs */ using Gtk; using System; class Hello { static void Main() { Application.Init (); Window window = new Window ("helloworld"); window.Show(); Application.Run (); } } /* end hello.cs */
There is an error:
$ gmcs hello.cs -pkg:gtk-sharp-2.0 alex@tomato:~/app/cv$ ./hello.exe Missing method System.Type::op_Inequality(Type,Type) in assembly /usr/lib/mono/2 .0/mscorlib.dll, referenced in assembly /usr/lib/mono/gac/gtk-sharp/2.12.0.0__35 e10195dab3c99f/gtk-sharp.dll Unhandled Exception: System.MissingMethodException: Method not found: 'System.Ty pe.op_Inequality'. at Gtk.Window..ctor (System.String title) [0x00000] in:0 at Hello.Main () [0x00000] in :0 [ERROR] FATAL UNHANDLED EXCEPTION: System.MissingMethodException: Method not fou nd: 'System.Type.op_Inequality'. at Gtk.Window..ctor (System.String title) [0x00000] in :0 at Hello.Main () [0x00000] in :0
Quite tragic, yes yes. Aside from this, very basic C# program appears to work on Ubuntu.
Next time I'll examine how Mono handles C# programs involving LINQ [wikipedia.org].
No comments:
Post a Comment