Writing Your First Program With Mono And MonoDevelop
Installing Mono And MonoDevelop on Gentoo and Debian/Ubuntu(5.10)
Installing Mono And MonoDevelop K/Ubuntu(6.06)
Mono applications can be developed using any text editor and the mono compiler(mcs). Type the following program in your favourite editor:
-
using System;
-
namespace FirstMono
-
{
-
class Hello
-
{
-
public static void Main(string[] args)
-
{
-
Console.WriteLine("Hello World!");
-
}
-
}
-
}

Now go to a shell prompt and compile and run the program:
sh# mono Hello.exe
You can copy the same Hello.exe file to a Windows machine and execute it there; you get the same output.
To create a C# application using the MonoDevelop development environment, follow these simple steps:
- Start Monodevelop from the GNOME/KDE menu.
- Select 'File->New Project' or press Ctrl-Shift-N to create a new Project/Solution. Select "C#" in the left pane and "Console Project" in the right pane of the dialog box.
- Type 'FirstMono' as the project name(in Location->Name field) and press the "New" button. You will see a sample C# file created in the open window(sample code is not created if "Blank Project" is selected in the "New Solution" Dialog box). Modify the string passed to the WriteLine() method if you wish.
- Select "Run->Build Solution" to build the project. Run the project using "Run->Run"(or press "F8"). The output is displayed in the Application Output window at the bottom.

Most of the frequently used operations(like "Build Solution", "Run" etc) can be invoked from the toolbar buttons too.
Related Posts:
Readers who viewed this page, also viewed:
- Finally Got 3D Desktop Effects in My Ubuntu Gutsy (ATI Hardware)
- Boost Filesystem Library: Writing Portable C++ Programs to Acess The Filesystem
- Installing C#, Mono(.NET) & MonoDevelop in Ubuntu Dapper Drake 6.06
- Create ASP.NET 1.0 & 2.0 Applications On GNU/Linux and Windows Using Mono XSP
- C# & MonoDevelop (.NET) on Gentoo and Ubuntu
Hi,
QuoteI've gotten everything to work wonderfully with Suse Linux Enterprise Desktop 10 except one thing. Every example I see shows that you can run a .net application directly from the command line. I always have to use mono to execute the binary. If I were to run ./HelloWorld.exe from the command prompt I get "cannot execute binary file" but by running it this way "mono HelloWorld.exe" everything works well. What am I missing? I have also checked to make sure the binary file is marked executable and group, user, and other has permission to execute.
Comment by Michael Painter — August 10, 2006 @ 10:30 pm
The rules are like this:
Instead of explaining all this in every example on Mono, people generally tend to just say 'execute the Mono app using `./HelloWorld.exe`' and let the user use whatever is appropriate in their case. I have adjusted the post to now use 'mono' to run the application.
QuoteComment by tabrez — August 11, 2006 @ 10:43 am
Thank you, that undoes all of the confusion!
QuoteComment by Michael Painter — August 11, 2006 @ 11:54 am
Quick and easy tutorial. Thanks!
QuoteComment by Marc — October 12, 2006 @ 2:56 am
Hi All,
MonoDevelop is good for Cross-platform .
iam using Monodevelop for my project.but i still i have one dought in Mono Reports.
MonoDevelop Supports ActiveReports and CrystalReport on linux and window?
Regards
Quotem m Kalyan
Comment by mohan kalyan — November 8, 2006 @ 6:30 pm
You can access the Crystal Reports from C#/Mono on Windows platform. Because CrystalReports.NET makes use of Win32 and COM API, it is not available on gnu/linux platform. You can access Crystal Reports.NET from Mono using the Web Service interface on either platform. ActiveReports is also not available on gnu/linux platform.
QuoteComment by tabrez — November 13, 2006 @ 1:40 pm
Pranjal Bathia on February 15, 2007 at 6:28 pm said:
We are using monodevelop for our BE project.We are having many doubts about using mono.Would u please help us?
Pranjal Bathia
QuoteComment by Pranjal Bathia — February 15, 2007 @ 6:28 pm
In Ubuntu 7.10 Gutsy, executing a Mono application can result in: bash: ./Foo.exe: cannot execute binary file
QuoteOr if using sh: ./Foo.exe: 1: MZ
But if you install the binfmt-support package, it will work.
openSUSE and SLED probably have a similar package.
Comment by Mark Strobert — January 10, 2008 @ 3:36 am
Man i was really confused but this short and simple tutorial was excellent.. ..Keep up the great job buddy :-)
QuoteComment by Rocky — May 28, 2008 @ 9:28 pm