Install mono and monodevelop

*** Draft ***

Install IDE

The goal is to have all development work done on Raspberry Pi. We will not be moving back and forth from Windows to Raspberry Pi.

And, we will be using monodevelop as IDE to code, debug, and test C# programs. Much like Visual Studio, the development work will be performed on full screen GUI mode.

Now, open Terminal session and enter the following commands to install mono and monodevelop.

sudo apt install mono-complete
sudo apt install monodevelop

Create Project Folder

The default folder for mono solutions is /home/user-name/Projects. For Raspbian, the default user-name is pi. For Ubuntu Mate, the user-name is the one that you created during initial configuration.

Either you are going to use the default folder, or you prefer to have a different folder, you should ensure the folder already existed.

You can create folder with File Manager.

Ubuntu Mate Only

With Ubuntu Mate, you can use Places on the menu bar, to manage files and folder.

Create the folder you need for your mono solutions. Assuming you are using the default folder, here is the screen after the folder is created.

Default Projects Location

From the menu, open MonoDevelop:

The first thing to do is to make sure the default folder for mono Solutions is correct.

From MonoDevelop menu, open Edit | Preferences. Navigate to Projects | Load/Save. Change the Default Solution location to the folder where you want to put your mono Solutions.

Hello World

Now, we are ready to create the Hello World program. With MonoDevelop opened, click on New under Solutions.

For Hello World, let’s create a Console Project.

Enter Project Name and Solution Name.

For the Location, it is best to leave it as the default as defined in the previous section. If you use a folder other than default, or if the folder specified in Location does not exist, you may encountered problems. The problem that I had before, was that MonoDevelop just closed without any message. Hopefully, same problem will not happen to you.

Click on Create button, MonoDevelop will create the skeleton program for you. And it is literally a Hello World program.

Expand the HelloWorld project on the left side of the screen. The structure is similar to projects in Visual Studdio.

Double click on Program.cs to see the program source code on the right side of the screen. It looks like this:

To run the program in debug mode, click the Run icon on upper left corner of the screen.

Click on Run menu to see other alternatives to run the program.

Ideally, the Hello World! message will be displayed on the Console. Just press any key to end debugging.

Well, it worked as expected on Unbuntu Mate. (The following screen is from Ubuntu Mate.)

Raspbian Only

With Raspbian, the program may just start and end without showing any messages. If your plan is to develop Form based applications, there is probably nothing to worry about. However, if you need to interact with console, there are two ways to fix the issue.

Application Output

If your program does not need to accept input (e.g. Console.ReadLine()) from the Console, you can redirect the output to Application Output. On MonoDevelop menu, select menu item Project | HelloWorld Options.

Expand the options to open Run | General. Uncheck Run on external console. Close the Options screen. Now, if you run (debug) the program again, you will see the Hello World! message on Application Output form.

Click on Application Output located at lower right corner of the screen.

Here is the message from the program.

Install xterm

(Note: I am not sure if this is a right solution. I was expecting all dependent packages should be included during the installation of MonoDevelop. So, missing a package doesn’t seem like something that should be happening. However, this is the best I can do for the moment.)

Open Terminal session. Enter command sudo apt install xterm to install the package.

Run HelloWorld program again. Now you can see the console.

(I had done some research on the threads…failed message on the Console. I couldn’t find a good solution. Again, this is not happening on Ubuntu Mate.)

Finally, we are done with the Hello World program. From this point on, you can either

  1. Learn more about plug-in and supporting packages for MonoDevelop. If you have large projects in mind, these packages should be helpful.
  2. Or, you can jump into database introduction. If you need to have database I/O in your program.
  3. Otherwise, jump to Interface with Hardware Components. This is probably the most fascinating feature when working on single board computer. Go ahead and have some fun.

Leave a Reply