Mono Binary

mono-binary

Mono(tm) Binary Kernel Support for Linux
—————————————-
Configurar Linux para la ejecución de binarios .NET creados apartir de la suite Mono sin necesitar el envoltorio o wrapper mono CLR, puedes usar simplemente el soporte BINFMT_MISC dentro del kernel. Esto te permite ejecutar binarios .NET basados en Mono. Como?

1) Simple, instalar la Suite de Mono ya sea desde fuentes o del binario que proporciona la pagina del proyecto.

2) Debes tener el kernel compilado con soporte BINFMT_MISC ya sea ke lo tengas como modulo o incluido dentro del kernel. Si optas por la primera opción (modulo), debes asegurarte de cargarlo en el arranque del sistema o cargarlo manualmente (ver man modprobe/insmod), a lo que lleva que debes compilarte un kernel a tu medida o bien fijarte si la distro que usas lo posee, que es lo mas seguro.

3) Puedes agregar las siguientes lineas a /etc/rc.local o script similar para que en el arranque sea automatico la puesta del nuevo registro de binarios, o hacerlo a mano.

# Insert BINFMT_MISC module into the kernel if [ ! -e /proc/sys/fs/binfmt_misc/register ];then /sbin/modprobe binfmt_misc
# Some distributions, like Fedora Core, perform
# the following command automatically when the
# binfmt_misc module is loaded into the kernel.
# Thus, it is possible that the following line
# is not needed at all. Look at /etc/modprobe.conf
# to check whether this is applicable or not. mount -t binfmt_misc none /proc/sys/fs/binfmt_misc fi
# Register support for .NET CLR binaries if [ -e /proc/sys/fs/binfmt_misc/register ]; then
# Replace /usr/bin/mono with the correct pathname to # the Mono CLR runtime (usually /usr/local/bin/mono # when compiling from sources or CVS). echo ‘:CLR:M::MZ::/usr/bin/mono:’ > /proc/sys/fs/binfmt_misc/register else echo “No binfmt_misc support” exit 1 fi
4) Una vez finalizado hagamos el canonico hola mundo. Test.cs
——————————–
using Gtk;
using System;
class Test {
Window w;
public Test ()
{
Application.Init ();
w = new Window (”Hiii World”);
w.DeleteEvent += new DeleteEventHandler (Salir);
w.SetPosition (WindowPosition.Mouse);
w.ShowAll (); Application.Run ();
}
static void Salir (object o, DeleteEventArgs args)
{
Application.Quit ();
}

public static void Main()
{
new Test ();
}
}
en shell:

$ mcs Test.cs -pkg:gtk-sharp
$ ./Test.exe

Si optas manualmente haz lo siguiente como root:
———————————————–

# modprobe binfmt_misc (Si esta como modulo si no obvia este paso)
# mount -t binfmt_misc none /proc/sys/fs/binfmt_misc # echo ‘:CLR:M::MZ::/usr/bin/mono:’ > /proc/sys/fs/binfmt_misc/register

NOTA: Enjoy it!!!! Observa que en este ejemplo la suite esta ubicada en /usr, por lo que el wrapper esta en /usr/bin/mono, si tienes el path diferente sustituyelo por tu propio path. Probado en Gentoo 2005.1, Fedora Cx, RedHat 8,9 y SuSE 8x y 9x.


Deja un comentario