Mono

From ArchWiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

From Wikipedia:

Mono is a [...] project to create a .NET Framework-compatible set of tools including, among others, a C# compiler and a Common Language Runtime.

Installation

Install the mono package.

If you need VisualBasic.Net support you have to install the VisualBasic.Net interpreter with the package mono-basicAUR.

MonoDevelop calls xterm when you run your project. You might install it, when you are writing a console application.

Note: Installing the package stores certificate authorities in /usr/share/.mono/certs/Trust/ but removing the package does not remove them.[1]

Running Mono applications

You can execute Mono binaries by calling mono manually:

$ mono programsname.exe

You can also execute Mono binaries directly, just like native binaries:

$ chmod 755 exefile.exe
$ ./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!

Development

Starting to develop in Mono/C# is very easy. Just install the MonoDevelop IDE with package monodevelop-stableAUR[broken link: package not found] or monodevelop-gitAUR[broken link: package not found]. Alternatively, you can install the riderAUR IDE.

If you want the API documentation browser and some testing and development tools you have to install mono-tools.

Troubleshooting

I get an error "cannot execute "path/to/your/binary" file name has not been set."

You might install xterm, since MonoDevelop starts xterm when you press on run. This might be a possible dependency.

I get an error when I try to run Mono binaries directly: "cannot execute binary file"

The binfmt_misc handler for Mono has not yet been set up, as explained in detail on the Mono Project website.

To fix this, restart the systemd-binfmt service.

I get an TLS handshake (or similar certificate based) error

Try mozroots --import --ask-remove which should update monos certificates. mozroots is part of the mono package.

I get an error when building fsharp: "System.TypeInitializationException: The type initializer for 'System.Console' threw an exception"

There is a recent bug in mcs that is used to build fsharp. A workaround is to use export TERM=xterm, as detailed here [2]

See also