Mono

Introduction
What is Mono?

"Mono provides the necessary software to develop and run .NET client and server applications on Linux, Solaris, Mac OS X, Windows, and Unix. Sponsored by Novell, the Mono open source project has an active and enthusiastic contributing community and is positioned to become the leading choice for development of Linux applications." - Mono Project

Preparing for Mono
Before we begin, let's determine all of our options.

Calculating dependencies... done! [ebuild N dev-lang/mono-2.6.7  USE="-hardened -minimal -moonlight -profile4 -xen"

USE
According to the official Gentoo documentation (http://www.gentoo.org/dyn/use-index.xml): USE Flag Descriptions If you have no knowledge of USE variables then you should take a look at the official documentation on portage.}}

Emerging Mono
Once you are entirely satisfied with your USE flags, you should check what is going to be installed to make sure all is well, and confirm if it is correct.

grsecurity problems
Mono cannot be installed if you are running grsecurity w/ PAX enabled, a simple fix to this is while emerging mono just execute the following script in another window; and with luck you will have mono installed shortly.

If the above does not work, make sure you have paxctl installed.

And that one of the above commands matches your mono version and portage temp path. One way to find these values is to run the emerge once and let it fail, then see the working path in the error messages.

Testing Mono
Navigate to a testing folder and create a new file with the following contents. ( is assumed.)

Then execute the following command: .

The "Mono Compiler Suite" compiles the source and outputs an executable. (test.exe) Time to test and see if everything is working, you should get the following result.

Then you have successfully installed Mono and are prepared to run .NET/Mono compiled applications.

Running Mono Applications
Then normal way to run a .NET application is with the mono command, which invokes the .NET runtime and executes the specified application, as shown in the previous section.

To execute non-native binary files, such as .NET executables, directly as if they were regular programs, the Linux kernel supports something known as the "misc" binary format. With this option enabled in the kernel (CONFIG_BINFMT_MISC), it is possible to register a "class" of executables (in our case .NET applications) and associate them with a "wrapper" program for execution (the mono command).

Once registered, .NET applications can be executed just like any native Linux application. To run the example application from the previous section, you'd simply type

In Gentoo you can use the init script provided by dev-dotnet/pe-format.

For more information on how to set this up, see Registering .exe as non-native binaries on the Mono project website.

Where To Go From Here?

 * Install if you're interested in using an IDE to develop .NET/Mono applications.
 * if you intend to run a Mono enabled apache server.