This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new!


Running .Net applications on Linux with Mono

By on April 25, 2006 (8:00:00 AM)

Share    Print    Comments   

Imagine the fate of your company rests on your completing your new Linux project on time. You have a crack team of first-class developers, but they're all .Net programmers. What are you going to do? Admit that Windows is better that Linux? Cry? Resign? No, you're going to install Mono and save the world!

Mono is an open source project (sponsored by Novell) that allows you to run .Net applications on Linux (as well as Unix, Mac OS X, Solaris and even Windows). To obtain it, go to the Mono download page and find the version you need for your distro.

Once you've installed Mono, get one of your .Net programmers to create and compile a simple Microsoft Visual Studio C# console application. Just something easy, such as:

using System;

namespace ConsoleApplication1
    class Program
        static void Main(string[] args)
            Console.WriteLine("Hello World");

If you don't have your own tame .Net programmer, you're going to need a Windows machine with Microsoft Visual Studio installed. (Stop making faces like that!) Download the free Microsoft Visual C# Express Edition.

Transfer the compiled application from the Windows machine by using FTP or Samba, then log on to your Linux box and run the application:

$ ConsoleApplication1.exe Hello World

Surely it can't be as simple as that? Amazingly, it is. If you don't believe that it's Mono that's allowing you to do this, try transferring the application to a Linux box that hasn't got Mono installed. You'll get a result something like:

$ ConsoleApplication1.exe
-bash: ./ConsoleApplication1.exe: cannot execute binary file

You may need to run chmod +x on the file to get it to run. Also, I found that on Debian at this stage I got an error: The assembly mscorlib.dll was not found or could not be loaded. It should have been installed in the '/usr/lib/mono/2.0/mscorlib.dll' directory. I cured that by executing:

$ cd /usr/lib/mono
$ sudo ln -s 1.0 2.0

The application name ends in .exe because it has been compiled as a Windows application. Once you've got it on Linux you can of course call it whatever you want:

$ mv ConsoleApplication1.exe  HelloWorld
$ HelloWorld
Hello World

You've just seen just how easy is to use a Microsoft Visual Studio application on Linux. However, you're also probably thinking that you have absolutely no intention of using Windows at all; your .Net programmers are just going to have to have to learn to program in something that runs solely on Linux. That's a good idea -- if you've got the time for them to learn something new. If not, don't despair. Mono comes with its own .Net compiler, mcs. To us it, paste the code for the 'Hello World' application above into a file, compile it (using mcs), then run the new application from the command line.

$ mcs -out:HelloWorld.exe Program.cs
$ HelloWorld.exe
Hello World

If you've still got that Windows machine fired up, you may find it interesting to transfer the newly compiled application to it and running your app in Windows. You'll find that you've created something on Linux that will also run on Windows.

Of course, by the time you've explained all this to your .Net programmers they'll be up in arms. "How can you expect us to program without a pretty GUI?" they'll cry.

"With Monodevelop," you'll say, referring to Mono's integrated development environment (IDE). With Monodevelop your developers can happily work with Glade#, Gnome#, and GTK#, all within a .Net-type environment. Check the software's download page for your distro's version and any dependencies.

When you install Glade, make sure that you obtain Glade2 and not Glade1. On Debian sudo apt-get install glade will grab Glade1, which will not work with Monodevelop. The correct installation command is sudo apt-get install glade-2.

The developers should leave you in peace for a while, but they'll be back. "Where's the GUI designer?" they'll ask. This is where you introduce them to building interfaces with Glade. When you start a new Monodevelop Glade# application, use a file called You can edit this with Glade and then do the programming in Monodevelop. If your developers have any further questions, point them in the direction of the Mono GTK# Beginner's Guide.

With your .Net programmers happily producing applications for Linux, you can turn your attention to ASP .Net for building Web applications. You're going to need a Web server, which can be either Apache (with mod_mono installed) or Mono's own Web server, XSP. Have a look at the Mono Handbook page for Web sites and Web services to find out how to set up the XSP server. On Debian, for example, its just a matter of installing the software:

sudo apt-get install mono-xsp

Then running it:

$ cd mono
$ xsp
Listening on port: 8080
Listening on address:
Root directory: /home/bainm/mono
Hit Return to stop the server.

XSP will run in the directory where you start it, will use this as its home directory, and will use port 8080 by default. If you don't want to have to change into that directory every time you start the server, you can use its --root option. To change the port, use the --port option:

$ xsp --root ~/mono --port 8081

When you've got your server up and running, go to Mono's Web Services page, where you'll find some good examples of the types of services that you can start running. However, if you're desperate to see the server in action, go to the directory you're running XSP from and cat the following into index.aspx:

<%@ Page Language="C#" %>
    Response.Output.Write("Hello World!");
</body> </html>

Now open up a Web browser and type in the URL of your host (plus the port number) -- e.g. http://hector:8080. Granted, this isn't the most exciting example in the world, but it proves that you can run ASP .Net on Linux. A quick search on Google will give you a host of other examples that you can use.

With Mono, Monodevelop, and XSP in place, you can throw away Microsoft Visual Studio and you can throw away Windows, and you don't have to throw away the valued experience of your .Net programmers.

Share    Print    Comments   


on Running .Net applications on Linux with Mono

Note: Comments are owned by the poster. We are not responsible for their content.


Posted by: blindcoder on April 25, 2006 05:07 PM
Admit that Windows is better that Linux?

<set mode='nitpick & troll & flame'>Are you implying that it is?</set>

Really, if you post stuff like this on Linux-friendly sites, please have a second or third thought about how you word some things.



Posted by: Drew on April 26, 2006 12:53 AM
If you read the whole sentence or better yet the article you see it is sarcasm.

"What are you going to do? Admit that Windows is better that Linux? Cry? Resign? No, you're going to install Mono and save the world!"


In order not to pay $3000 to Microsoft?

Posted by: Anonymous Coward on April 25, 2006 06:41 PM
Assume you have developed your killer ASP.NET application that uses ASP.NET form authentification (not Active Directory) and now your customers asks for a price.

You start by saying your price and then you tell them they need Windows 2003 Server, and CALs (client access licenses).

The price for your application increased with $500 for Windows + $3000 for an external connector license.

I do not understand why open source people still create ASP.NET applications like DOTNUKE, since all these installations needs the external connector?

Or is Microsoft just ignoring that almost all ASP.NET sites around the world isn't licensed correctly? Will MS first bother when Linux isn't a threat anymore?


Re:In order not to pay $3000 to Microsoft?

Posted by: Anonymous Coward on April 26, 2006 10:59 PM
The sole reason i still use php over is for every one script that is free, php has about a million.<nobr> <wbr></nobr>:) Now being a poor college student what one do you think i will go for?

BTW, mono + c# = lots of fun. It is fun to freak out prof when running c# apps from *nix.<nobr> <wbr></nobr>:)

Lastly, i should really make an account here.


Re:In order not to pay $3000 to Microsoft?

Posted by: Anonymous Coward on May 10, 2006 10:14 AM
3000 k... 8/


relief joint

Posted by: Anonymous Coward on May 28, 2006 06:02 PM
<tt>[URL=] Pain relief [/URL]
[URL=] Back Pain [/URL]
[URL=] Pain relief [/URL]
[URL=http://painreliefmedic.friendpages.c<nobr>o<wbr></nobr> m] Pain relief [/URL]
[URL=<nobr>i<wbr></nobr> nrelief.htm] Nerve pain relief [/URL]</tt>


Great Stuff

Posted by: Anonymous Coward on April 25, 2006 07:12 PM
Great article. It was well written, humour-filled
and easy to follow.


a crack team

Posted by: Anonymous Coward on April 25, 2006 07:13 PM
``a crack team of first-class developers, but they're all<nobr> <wbr></nobr>.Net programmers.''

How can this be?


Re:a crack team

Posted by: Anonymous Coward on April 27, 2006 02:36 AM
I agree. A "crack team" of developers is a team whose members know several programming languages, and that means, at a *minimum*, the following:

UNIX shell scripting (csh and bsh)
PERL and/or PHP

These are the languages that actually power the Internet. "First-class" developers are able to, already have, and are currently, writing software that drives the Internet. Any "first-class" developer would know more languages as well. Simply knowing Visual BASIC, or C#, or being helpless without MS Visual Studio and its Microsoft Foundation Classes, makes you a Windows programmer, not a "first-class developer."

The reason for this is simple. Program logic is program logic; one language just expresses that logic one way, another does it another way, but it's the same logic. The biggest part of software development is logical thought and planning. This is what makes folks like RMS, Linus, Alan Cox, Theo, etc. so good at it. These folks are truly first-class developers. In a minimum of time, they could sit down and competently use *any* general-purpose language to accomplish a given goal.


Re:a crack team

Posted by: Anonymous Coward on May 21, 2006 11:54 PM
This was _exactly_ my reaction. If they are<nobr> <wbr></nobr>.Net programmers, then they sure as hell are _not_ good programmers. Good programmers understand that OSS shall rule the world and are running away from proprietary software development platforms as fast as they can.

--Paul Bain


Re:a crack team

Posted by: Anonymous Coward on January 04, 2007 05:44 AM
You are all very misinformed.

c# is a very elegant language. I can code in c, c++, LISP, VB (zeus help me), or Java but I prefer c# any day.

You can feel free to malloc to your hearts content or point into invalid memory. I prefer to focus on clean, debuggable code.


Re:a crack team

Posted by: Administrator on April 25, 2006 11:35 PM
Well that depends on your definition of 'crack'.


but what about apps that use IE hooks?

Posted by: Anonymous Coward on April 25, 2006 10:09 PM
what if the<nobr> <wbr></nobr>.net app "relies" on IE for functionality? or does this matter?

(note: i'm not a developer)

- shawn


Pain relief

Posted by: Anonymous Coward on May 28, 2006 06:08 PM
[URL=] Pain relief [/URL]

  [URL=] Back Pain [/URL]

  [URL=] Pain relief [/URL]
[URL=] Pain relief [/URL]
[URL=<nobr>.<wbr></nobr> htm] Nerve pain relief [/URL]


lower back pain

Posted by: Anonymous Coward on May 30, 2006 02:04 AM
[URL=<nobr>.<wbr></nobr> htm] Nerve pain relief [/URL]

  [URL=<nobr>k<wbr></nobr> pain.htm] Low back pain [/URL]

  [URL=<nobr>b<wbr></nobr> ackpainrelief.htm] Back pain relief [/URL]

  [URL=<nobr>l<wbr></nobr> es/kneepainrelief.htm] Knee pain relief [/URL]

  [URL=<nobr>e<wbr></nobr> lief.html] Pain relief [/URL]

  [URL=<nobr>i<wbr></nobr> nrelief/painreliefpreved.htm] Pain relief [/URL]

  [URL=<nobr>t<wbr></nobr> ion-Pain-Relief.html] Medication pain relief [/URL]

  [URL=<nobr>l<wbr></nobr> -Pain-Relief.html] Natural pain relief [/URL]

  [URL=] Pain relief [/URL]

  [URL=] Back Pain [/URL]

  [URL=] Pain relief [/URL]
[URL=] Pain relief [/URL]


This article

Posted by: Anonymous Coward on April 26, 2006 04:55 AM
You should not link 2.0 to 1.0.
In debian you should just install the 2.0 profile which is probably in mono-classlib-2.0 package (or something like that).


Open source at the expense of your business....?

Posted by: Anonymous Coward on April 26, 2006 12:56 PM
So you have a project that is behind, and you want to run it on Linux for what reason? Performance & stability? Cost? Ok, great. So then you choose to run it on Mono, with a bunch of 80% complete, 1/2 supported development tools, rather than doing one of:

1) Developing it on Linux with Linux proven tools that are stable TODAY (C++, Java, Perl, Python, Ruby?), or...
2) Develop it and run it on Windows with a<nobr> <wbr></nobr>.NET IDE like Visual Studio or Borland Delphi that is stable TODAY AND has commercial support behind it.

I'm all for Mono's success, and the article is novel, but it shows the author's lack of experience on critical projects. I run my company with a mix of Open Source and commercial software. You don't go pick a bunch of beta tools to deliver a time sensitive solution, unless you also like Russian Roulette. Hello world does not equal a true application.


Before you "save the world" with mono...

Posted by: Anonymous Coward on April 26, 2006 04:45 PM
... I think this is worth reading:
<a href="" title=""></a>


hello world not an application

Posted by: Anonymous Coward on April 26, 2006 10:23 PM
I have to agree with another comment that Hello World is not a good example of an application. The Hello World application is by definition the most simplistic application you can write in a programming language.
Real world applications deal with GUI interfaces, database connectivity, web connectivity, file systems, etc.

<nobr> <wbr></nobr>.Net on windows uses windows.form<nobr> <wbr></nobr>.Net framework to draw the gui. This is not mature on Mono. Programmers on Mono typically use the Gtk# framework for gui's (obviously not supported on MS<nobr> <wbr></nobr>.Net). The reason is the windows.forms framework for Mono is neither fully implemented and is ugly as heck.

Console applications with limited OS interaction work great between OS's. Complex<nobr> <wbr></nobr>.Net applications have a ways to go.


Re:hello world not an application

Posted by: Anonymous Coward on May 06, 2006 12:57 AM
Why isn't hello world a real app?

Webmaster mmofx(<a href="" title="">wow gold</a>)


hello retard

Posted by: Anonymous Coward on April 27, 2006 10:11 PM
I'm tired of these stupid Hello World apps. Write an app that does something, then compile with Mono.

If you have to have something that is dead simple, there are so many better examples that are still pretty simple, like calling a web service for example.


Re:hello retard

Posted by: Anonymous Coward on April 28, 2006 04:13 PM
What makes the "hello world" example any worse than some other simple example?

The purpose is to see that the binary file is runnable and does what it is expected to do...

Hello World rules<nobr> <wbr></nobr>;)


Re:hello retard

Posted by: Anonymous Coward on April 30, 2006 08:38 AM
Lets not call someone a retard. Keep it real. However, there are thousands of toy languages out there that will run "Hello World" and that doesn't make them a viable option to consider for developing a production application.

The author presented Mono and Mono development tools as an "option" to deliver a late Linux project. People who actually use Visual Studio and Mono will tell you Mono is not there yet. There are plenty of other examples of<nobr> <wbr></nobr>.NET apps that will not run on Mono. His example did not prove anything, except that Mono is capable of running some<nobr> <wbr></nobr>.NET apps, specifically Hello World.

This is all beside the point. Why combine Linux (mature and stable) + Mono (immature, beta and incomplete)? It doesn't make sense. The article comes off sounding novel and neato, but lacks a supporting argument for using Mono over other mature options on Windows or Linux.


Back Pain relief

Posted by: Anonymous Coward on May 28, 2006 03:29 PM
<tt>[URL=] Pain relief [/URL]
[URL=] Back Pain [/URL]
[URL=] Pain relief [/URL]
[URL=http://painreliefmedic.friendpages.c<nobr>o<wbr></nobr> m] Pain relief [/URL]
[URL=<nobr>i<wbr></nobr> nrelief.htm] Nerve pain relief [/URL]</tt>



Posted by: Anonymous Coward on August 03, 2006 06:40 PM
Mono is still far behind. For<nobr> <wbr></nobr>.net developers that need the generics, good database support you still have to use<nobr> <wbr></nobr>.NET.

Compile a program which has one of these in it:
List L = new List();
SqlCommand S = new SQLCommand();

Two important parts of<nobr> <wbr></nobr>.NET among a lot of others that are not available and are critical for modern programming. If Mono is up to specs with<nobr> <wbr></nobr>.NET 2.0<nobr> <wbr></nobr>.NET will be in version 3 with LINQ.
Mono needs a substantial amount of support will it ever reach the same level. Just look at the docs. They are incomplete and/or out of date.
No professionla programmer can work with that.


Re:Running exe on Fedora

Posted by: Anonymous Coward on August 25, 2006 04:02 AM
check out the mono support in the linux kernel:
<a href="" title=""><nobr>.<wbr></nobr> txt</a>

compile it in. viola!


Re:Running exe on Fedora

Posted by: Anonymous Coward on October 14, 2006 03:58 AM
Compile it in and I get a stringed instrument...intriguing...


What about...

Posted by: Administrator on April 25, 2006 11:49 PM
The Windows-specific libraries that most<nobr> <wbr></nobr>.NET applications are bound to rely on?

C++ is C++, it's kinda useless to use CRL to make an app that doesn't involve Windows libraries in any way, and even more useless to go through the trouble of running it in Linux with Mono if you can just recompile it.

Will those<nobr> <wbr></nobr>.NET libraries run with Mono too? Or can the programs link to the DLL clones provided by Wine?


debian and ubuntu users guide

Posted by: Administrator on November 12, 2006 03:16 AM
debian and ubuntu users if you want to install mono and xsp follow <a href="" title=""> this simple guide</a>



Posted by: Administrator on June 10, 2006 09:33 PM
dlinux community z d most advancing os community in dwhole world and am happy am a distinguished member o fthe club . I sin crelt 4see the revolutionary processes goning on in the industry and am sure in te near future if te paces are kept up linux will catch up or even overtake allmightyu microsoft windows


Running exe on Fedora

Posted by: Administrator on August 16, 2006 06:14 PM
Hi there, I tried running your code on my Fedora 5 box and received the error you mention "cannot execute binary file", however, if I prefix the exe with "mono", it works. I can't get anything to run the way you describe, even creating programs on linux and compiling them, they will not run without invoking the mono shell



yes mono runs windows apps

Posted by: Administrator on October 09, 2006 06:19 AM
A company who created CRM on Windows<nobr> <wbr></nobr>.Net transferred it a SUSE Linux system and it just run.

see here <a href="" title=""><nobr>2<wbr></nobr> 0/Default.aspx</a>


Running .Net applications on Linux with Mono

Posted by: Anonymous [ip:] on October 28, 2007 12:01 PM
There is also a mono included precompiled livecd called monoppix.
Roiy Zysman


Running .Net applications on Linux with Mono

Posted by: Anonymous [ip:] on December 21, 2007 01:12 PM
Dear Bain:

I am a Linux user; I do not run Windows OS. I had developed a .NET software using windows forms 2 years ago. Now, I want to run that on my Debian. I do not know how to run it, because the program is very complex (kind of). Also, my machine does not run the .exe file that is generated during the compilation. Any suggestions at this point? If you would like, I shall mail the source code to you. The code is not in a single file (because it is a windows forms application).

Deepak B M


This story has been archived. Comments can no longer be posted.

Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya