Getting started with MonoDevelop


MonoDevelop: MonoDevelop is a free GNOME IDE primarily designed for C# and other .NET languages. MonoDevelop makes it easy for developers to port .NET applications created with Visual Studio to Linux and to maintain a single code base for all platforms. It supports Linux, Windows and Mac OSX.

The main features of MonoDevelop:-

  • Multi-Platform.
  • Support for ASP.NET projects, allowing web projects can be built and tested on XSP.
  • Class Management.
  • Code Compilation.
  • Built-in Help.
  • Add-ins.
  • Support for MonoTouch and Mono for Android.
  • Support for version control and source editing.
  • Integrated Debugger.

The History of MonoDevelop: The MonoDevelop application is based upon a previous open-source IDE called SharpDevelop (also known as #develop).This was a C# and VB .NETdevelopment environment available as a free download. Its source was taken and ported to use the GNOME toolkit (Gtk+) framework and to use the Mono development platform for compilation. It's not the only IDE available to you, Although you could continue to use #develop, you could use the command line and a GUI editor, or you could use a commercial offering such as X-develop.

Introducing the MonoDevelop Layout: MonoDevelop consists of a main application window and a number of internal windows and tabs that present various pieces of functionality.
layout-monodevelop.gif

Figure 1.1: Exploring the MonoDevelop layout

  • The Menu: The menu represents the functionality available to you through the IDE, with elements becoming
    enabled or disabled as appropriate.

  • The Toolbar:The toolbar represents commonly used pieces of functionality that, like a keyboard shortcut, are presented on the toolbar for ease of use. Whilst the toolbar cannot be customized in the current version of the IDE, you can add useful tools to the Tools menu through an option within the File-> Preferences menu. This allows you to reference external tools that can then be launched from within the MonoDevelop environment.

  • The Main Source Window: The main code window (or windows, if more than one source file is open) displays a particular source file that you have either opened or created. Each source file has a tab associated with it, showing the name of the file. If you open more than one source file, then more than one tab will display, providing you with the ability to switch between source windows with the click of a button.

  • The Solution Explorer: The Solution Explorer uses the same technique as the main code window, allowing you to see different views of your solution by simply clicking the tab that denotes the view you want to see.

    solution-explorer.gif

    Figure 1.2: Solution Explorer

The Task window shows actions that need to be resolved; the most common use for this window is that if compilation fails, the window lists the tasks related to the errors found in the code.

Finally, the Output window shows the results of any output that may derive from an action within the IDE. For example, if you compile a source file, then the progress and results of this will display in the Output window.

Creating a Project

The first step in using your IDE is to create a project that can then be used to target a specific application type, compile the source files contained within it, and build the target executable.

The first step is to create your solution, that is, combination of files. Select File-> New Solution/Project from the menu. The New Solution dialog box will open. You need to select the type of project you're creating, so in this instance select C# and then choose C# Console Project from the options available.

new-solution.gif

Figure 1.3: Using the New Solution dialog box

You'll need to assign a name for the combine file, a location on your file system, and any subdirectory you want to use.

When you are ready, click the New button on the dialog box, and your combine solution will be created.

You should see a screen similar to the one below:-

new-project.gif


Figure 1.4: Viewing an empty solution

What's a Solution Used For?

Solution acts as a container for your project files. A solution is typically split into one or more projects that define a deliverable element. In addition, the concept of a project not only acts as a container for files that are used within the solution but also stores other attributes that are used to build the target. These attributes are usually represented by parameters that can be given to the compiler; for example, the /target option dictates the target type for its output. Therefore, a solution is your friend; if you select the assembly solution type, you can expect this to automatically apply the /target:library option.

Adding Project Files

So, you have your solution created with a single project called NewProject, although at the moment no source files are present. Let's add a single source file that represents the application. You can achieve this in a number of ways:

You can choose the Add Files icon depicted in Figure:-

ADD-FILES.gif

Figure 1.5: Adding a project file

The Add New File dialog box will display, showing a list of support languages in the left pane; after selecting your chosen language, you'll see a list of recognized file types on the right side. In below figure , you can see that I've selected C# as the language and Empty File as
the file type.

new-file.gif

Figure 1.6: Selecting the language and file type

Configuring your Target Output

Once you've added your file, you have some control over your project's options. The Project Options dialog box (available too from the context menu after right-clicking) allows you choose which files you want to compile and how, although at this stage you have already decided to build a C# console project and so should leave these options.

projectoptions.gif

Figure 1.7: Setting the Mono project options

Building Your Target

Once you have created your solution, added a project, and included the necessary file, you are ready to compile the main application source code and build your target executable. As usual, you have a number of options. You can choose Build-> Build All or Run-> Debug. In this example, this will compile the console application using the source file added. If the process is successful, it will leave an executable on disk. After you have chosen to compile the project using one of these methods, the Outputwindow should show the results of the compilation process, as shown in Figure 1.8.

build-succesful-3.3.11.gif

Figure 1.8: Viewing the successful build results

Testing your Target

Finally, you've created the project, added the source file, and successfully built your first application using MonoDevelop.You can now test this by selecting Run-> Run or by clicking the "Run" icon and a separate window appears like this ,as shown in figure:

output.gif

Figure 1.9: Viewing the output from the Hello world application

You've now created a basic MonoDevelop solution that holds the single "Hello World" project. This in turn holds a single C# source file called "Hello World.cs" and when compiled, forms a console based executable that outputs the string "Hello World!" to the standard Output window.


Similar Articles