Beeing able to double click, or simply ./app.exe from the console, is always easier that calling Mono or Wine. The Linux Kernel provides a feature that enables developers to hook and make .exe to be recognized and started as an excutable but the current solutions are not compatible between themselves. I tough that doing an application to detect which .exe’s are .NET ones and lauching the correct application to read them would be a nice little project.
I decided to hack it with C++ (with my very poor C/C++ experience) and started to look for information about it. Sadly there is not much, well formatted and organized, data about the subject. There is specially a lack of examples. With the help of some bits of data here and there, and by analysing mono source code, I was able to put it together. I could had simply copy pasted the Mono code but that would be a huge waste of memory, because this library doesn’t really need all that data strutures. In fact, it only needs to read less than 100 bytes from the file, altough its a random read.
I created an application called clrx that checks if a file is a valid .Net file. You can download it here. I say “file” because both .Net EXE and DLL files are validated. After you install it you can simply:
And it will tell if it is, or not, a valid .Net file.
To build and install it:
tar -zxf clrx-1.0.tar.gz
sudo make install
Then you need to copy autoexe and autoexe-setup to /usr/local/bin. Alternatively you can simply uncompress the file, cd to the directory and, as root, execute the “install” script in there. It will do all the steps.
Because I didn’t want to waste time creating configuration files and checking paths, I simply created a script that will invoke clrx and based on the output it will call either Mono or Wine. I called this script autoexe and it can be configured in binfmt_mist with the following command as root:
echo ‘:CLR:M::MZ::/usr/local/bin/autoexe:’ > /proc/sys/fs/binfmt_misc/register
If you currently have the Wine “service” running at boot or is by some other way you are already registering EXE files to either Mono or Wine, you need to undo the respective command and change it to the provided one. To make things easier, there is a autoexe-setup that will do this.
I believe this would be a nice improvement to both Mono and Wine to include this on their releases