Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

When running a .net program on Ubuntu I have to type in "mono foo.exe" instead of just foo.exe or double-clicking the icon. Is there any way to just run foo.exe?

share|improve this question
add comment

3 Answers

up vote 14 down vote accepted

Does this link help? Running Mono

From the Mono Project on using binfmt:

Registering .exe as non-native binaries (Linux only)

Because this is a Linux-specific feature, we do not recommend that developers deploy this solution, as it would limit the portability of their scripts.

In addition, this mechanism does not work as intended by the Application Deployment Guidelines.

You can also make a systemwide change, and use binfmt to register the exe files as non-native binaries. Then, when trying to launch an exe file, the kernel will run the mono interpreter to handle the command. Binfmt can also be used to launch Windows executables using WINE, or Java .class files using a JVM. To register exe with the kernel:

Become root and turn on the binfmt module in your kernel with this command:

modprobe binfmt

In addition, you may want to add that command to your /etc/rc.local boot script, so that it will be executed on boot.

Add the line below to your /etc/fstab file:

binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc none

Then, have your system run the following command on boot:

echo ':CLR:M::MZ::/usr/bin/mono:' > /proc/sys/fs/binfmt_misc/register

Be sure to mark your .exe files as executable in the filesystem as well:

chmod +x myprogram.exe

Note that this doesn't change your kernel, just the modules that it loads when you boot your system. In other words, you can still upgrade your kernel without worrying about losing these changes. Similarly, you can upgrade your Mono runtime without affecting any of the invocation methods listed in this section.

share|improve this answer
    
+1 for binfmt_misc option, which is the smallest workaround on Linux –  mario Jan 6 '11 at 2:17
1  
got FATAL: Module binfmt not found in 12.04 –  RiaD Aug 17 '12 at 18:47
add comment

Create a startup script.

Open a plain text editor, add this:

#!/bin/bash
mono foo.exe &

Depending on your setup, you may need to use the full path for foo.exe.

Save the file for example as foo.sh.

Make it executable:

sudo chmod a+x foo.sh

You should now be able to start foo.exe by double-clicking foo.sh.

share|improve this answer
add comment

You can associate the file extension '.exe' on Nautilus to be executed with /usr/bin/mono

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.