Installing Mono on Raspberry Pi

Now, how do I use Mono on my Raspberry Pi ?

Installing Mono

First, you have to install the Mono framework, which is pretty easy :

$ sudo apt-get update
$ sudo apt-get install mono-runtime

This will update the package list and install the Mono runtime.

Running Programs

Once done, you’re ready to run Mono/.NET programs.

Usually, a Test.exe program must be started as follow:

mono Test.exe

Or, if your program requires elevated rights:

sudo mono Test.exe

Writing Programs

If you’re familiar with Visual Studio, the best you can do is… to use Visual Studio! Once compiled, programs created with Visual Studio will run on Mono (well, you will soon discover that some restrictions apply).

In order to test your Mono setup, create a new Console application (target it for .NET Framework 2.0 or .NET Framework 4.0):

using System;

namespace Test
    class Program
        static void Main(string[] args)
            Console.WriteLine("Running on {0}", Environment.OSVersion);

            Console.WriteLine("Press a key to continue");

Compile, copy the .exe file to your Raspberry Pi, run the program (mind the case!)

$ mono Test.exe

Enjoy the result!

Running on Unix
Press a key to continue

You will soon discover that there’s a problem with DateTime on hard-float ABI systems. You may choose to use a ‘Soft-float’ Raspbian until a fixed release of Mono is available… but that’s another story!

This entry was posted in Mono Framework by Eric Bézine. Bookmark the permalink.

About Eric Bézine

Having started programming in the early ages of Personal Computer on the family Thomson TO7-70 (i.e with 70KB memory), Eric grew as a software engineer, made Microsoft .NET its favorite playground and is now Platform Architect for a software editor in the tourism market. Apart from programming, the young Eric passed its free time to play Lego and assemble electronics circuits. Time has passed since then! Arrival of "micro-computers", as Raspberry is, having ability to drive external components, as well as respond to external stimuli, opened a range of new opportunities... Let's enjoy them !

13 thoughts on “Installing Mono on Raspberry Pi

  1. I followed your easy steps, thanks for supplying them. But now it only installed framework 4.0. And my VS C# 2008 is only willing to work with framework 3.5 or lower.

    Is there a way I can install the 2.0 framework afterwards?

    • Running programs built with VS 2013 works for me only after installing the complete package. No mather what target framework I choose, Mono is alwas missing the 2.0 assemblies on my installation.

      After installing the complete Mono framework using

      sudo apt-get install mono-complete

      I have 2.0, 4.0 and 4.5 libs installed on my installation.

  2. Hi,

    Thanks for the tutorial. You have made it simple;)
    However, this brings a couple of important questions to my mind:
    1) How is it in performance as compared to say C++, Python on Raspberry PI instead of running C# applications (that target the CLR), for the same program. Any idea?
    2) Is not it a hack running C# on Mono. I read that Mono on Raspbian may not support .NET 3.5 onwards.

    Please comment. Thanks.

    • Played with C#/mono on my rpi this evening, and while it is slightly slower than ‘equivalent’ c it is not that bad, in fact it seems to shine when your string objects get *really* big. Started in c# with a prog that loops a lot doing various int, float and string manipulations, then ported that over to c. Results are consistent and good enough that I am seriously considering using it over python for my rpi projects – or at least considering it…

      Is it stable? 😉

  3. I followed the steps above and when i try to compile i get the following messge “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 verified there is no such directory. i have /usr/lib/mono/4.0 and 4.5. Is there a way to point mono to use 4.0 and not 2.0?

  4. Pingback: Which OS image is the easiest to use with mono-runtime? | CL-UAT

  5. Pingback: Reaktionszeit-Vergleich: Raspberry Pi 2 Windows 10 vs Mono vs Python vs .Net Micro Framework vs Arduino |

  6. I’m trying to start in the raspbian world, but right now I’m selecting the language to do it I don’t like python, I will like to use c#and mono by I don’t find anything about how to access spi, uart or gpio, some one can tell me if it is possible to access the hardware modules using mono??

  7. Hii,
    Thanks for tutorial,
    I want to ask , I want to start making project with Pi Raspiberry 3 with the C # language , and I wanted to use the MonoDevelop and Xamarin
    Where should I start from her , and what do I need?

  8. For get last mono on raspbian follow this instructions:
    1. sudo apt-key adv –keyserver hkp:// –recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
    2. echo “deb wheezy main” | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
    3. sudo apt-get update
    4. echo “deb wheezy-apache24-compat main” | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list
    5. echo “deb wheezy-libjpeg62-compat main” | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list
    6. sudo apt-get install mono-devel
    7. sudo apt-get install mono-complete
    8. sudo apt-get install referenceassemblies-pcl
    9. sudo apt-get install ca-certificates-mono
    10. sudo apt-get install mono-xsp4

    After finish installed :
    root@p1:~# mono –version

    Mono JIT compiler version 4.4.2 (Stable Fri Jul 29 10:21:58 UTC 2016)
    Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors.
    TLS: __thread
    SIGSEGV: normal
    Notifications: epoll
    Architecture: armel,vfp+hard
    Disabled: none
    Misc: softdebug
    LLVM: supported, not enabled.
    GC: sgen

Leave a Reply

Your email address will not be published. Required fields are marked *