Difference between revisions of "Mono"

From ArchWiki
Jump to: navigation, search
(Registering Mono Applications with the Kernel)
(Registering Mono Applications with the Kernel)
Line 16: Line 16:
 
  mono programsname.exe
 
  mono programsname.exe
  
It is also possible to tell the kernel to use '''mono''' as an interpreter for all Mono binaries. First mount the binfmt_misc filesystem:
+
It is also possible to tell the kernel to use '''mono''' as an interpreter for all Mono binaries. For doing this, just add mono to your daemons array in /etc/rc.conf and it will be automatically setup for you.
  
  mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
+
  DAEMONS=( ..... mono .... )
 
+
or add this line to your '''/etc/fstab'''
+
 
+
none  /proc/sys/fs/binfmt_misc binfmt_misc defaults 0 0
+
 
+
Then tell the kernel how to interpret Mono binaries:
+
 
+
echo ':CLR:M::MZ::/usr/bin/mono:' > /proc/sys/fs/binfmt_misc/register
+
 
+
You can add this line to '''/etc/rc.local''' to make this setting permanent. In this case you may want to ignore stderr to avoid error messages when changing runlevels:
+
 
+
{ echo ':CLR:M::MZ::/usr/bin/mono:' > /proc/sys/fs/binfmt_misc/register; } 2>/dev/null
+
  
 
Now try this:
 
Now try this:

Revision as of 09:45, 25 March 2009


Introduction

Mono is an open source, unix implementation of the Microsoft .NET framework.

Installation

First install mono with pacman:

# pacman -Sy mono

Registering Mono Applications with the Kernel

You can execute binaries by calling mono manually

mono programsname.exe

It is also possible to tell the kernel to use mono as an interpreter for all Mono binaries. For doing this, just add mono to your daemons array in /etc/rc.conf and it will be automatically setup for you.

DAEMONS=( ..... mono .... )

Now try this:

chmod 755 exefile.exe

Testing Mono

Make a new file; test.cs

using System;

public class Test {
 public static void Main(string[] args) {
  Console.WriteLine("Hello World!");
 }
}

Then run:

$ mcs test.cs
$ mono test.exe
Hello world!

Resources

Official Mono website