79

I've seen a lot of talk about running Mono/.NET code on the Raspberry Pi. Has there been any success in actually running any Mono code on a Raspberry Pi?

On their site, they list several Linux distributions that work on the device and some of these distributions include Mono. However, none detail whether Mono works on it.

Is there a working implementation?

Andrey Portnoy
  • 1,430
  • 15
  • 24
AngryHacker
  • 59,598
  • 102
  • 325
  • 594
  • 2
    possible duplicate of [MonoDevelop ARMv6 Raspberry PI](http://stackoverflow.com/questions/9547047/monodevelop-armv6-raspberry-pi) – skolima Apr 18 '12 at 16:23
  • 20
    That question is about MonoDevelop (the IDE) rather than the runtime, I think this will be first hit by developers wanting to use Mono on the Raspberry Pi, not the other one. – Ani Apr 18 '12 at 18:24
  • I agree, running mono is quite different from running MonoDevelop. This is a legitimate separate question. – Joe Strout Mar 11 '13 at 15:12
  • I was able to run WCF service with EntityFramework consuming MySql database installed on Pi. It was just a test project, but performance was good. – vpetrovic Oct 26 '15 at 11:47

8 Answers8

32

I have managed to run my Delta Forth .NET compiler on Debian 6.0 (Squeeze) and Mono. It worked flawlessly with full binary compatibility, the only thing I had to do was to recompile the code to target .NET 3.5 (instead of 4.0) since Mono on Debian lags a bit regarding .NET versions.

The compiler is not a trivial .NET application so I was happy to actually see the compiler in action on my tiny Raspberry Pi.

The actual steps I took to make the magic happen were (I recall from memory):

  • Install the Mono runtime using: sudo apt-get install mono
  • Invoke the compiler itself using: mono DeltaForth.exe file_to_compile.4th

That is all. The most challenging part of this endeavor was to transfer the files from my Windows machine to Raspberry Pi using a flash drive :-)

vbocan
  • 1,364
  • 1
  • 12
  • 18
  • 9
    'sudo apt-get install mono' did not work for me. I used 'sudo apt-get install mono-complete'.. it seems to work so far! – kodybrown Dec 17 '12 at 21:54
  • 2
    Side note for those looking to compile.. I had to use 'mcs sample.cs' to compile my code on the raspi and 'mono sample.exe' to run it.. it works, so I'm totally excited to be able to program c# on my pi :-D – kodybrown Dec 22 '12 at 10:37
  • 2
    @wasatchwizard - its not "mono" but "mono-runtime", the "mono-complete" does work too, but its MUCH larger and EVERY part of mono, so you get a lot of extra libraries. If you are trying to build a small footprint, that package is not the solution - but I prefere it too, eventhough it takes ages to install. – BerggreenDK Feb 25 '13 at 22:36
  • 3
    @vbocan -I just mount a CIFS network drive onto my PC/LAN and then use MonoDeveloper to compile the mono.exe files with full speed on a modern PC (Intel Core i7). Then when the binary is done, it just execute it over LAN on the Raspberry PI.. works as a charm! and compiling is a breeze. – BerggreenDK Feb 25 '13 at 22:38
  • 4
    Next time, SCP your files to your Raspberry pi instead using a flash drive. On Windows you can use WinSCP for that. – Tom van Zummeren Mar 08 '13 at 20:43
  • @BerggreenDK do you have any more info on how you compiled mono using CIFS on your i7? I have been trying QEMU and... well no luck. Trying to compile mono for the 4th time on my Pi :( – Piotr Kula Feb 20 '15 at 18:47
  • sorry, havent touch my Pi for 1½ years, it was slow and the issues back then with DateTime etc. made me go in other directions until fixed. – BerggreenDK Apr 07 '15 at 08:15
21

The folks on the Raspberri Pi board are reporting that Mono does indeed work, at least for simple applications.

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
AngryHacker
  • 59,598
  • 102
  • 325
  • 594
  • but with bugs at the moment as DateTime isnt working as expected when using stringformatting – BerggreenDK Feb 25 '13 at 22:35
  • It's not just DateTime's string formatting. The problems are deep and pervasive, alas. See the bug report (https://bugzilla.xamarin.com/show_bug.cgi?id=7938) and the others linked to that one. – Joe Strout Mar 11 '13 at 15:14
  • DateTime issues sound like soft/hard float problems. You need a soft float distro for mono 2. You can use a hard float distro if you use mono 3 (you may need to compile mono yourself, which isn't that hard). – fiat Jan 12 '14 at 02:30
19

Mono on the Raspberry Pi is possible and reasonably easy to set up. The following assumes you're on Debian. This is taken from my blog that offers a number of Raspberry Pi tutorials

A note: the standard Mono runtime currently available only supports up to .NET 3.5 unless you compile from source yourself.

So you want to start developing some applications for your Raspberry Pi but your knowledge of programming is limited to the modern .NET languages such as VB.NET and C#. Not a problem!! Welcome to the world of Mono, an open source cross-platform and compatible version of the .NET framework. By using a development IDE such as Visual studio, or even better MonoDevelop you can produce EXE files that will run on your Raspberry Pi. All you need to do is to install the Mono run times on the Raspberry Pi. To do that we enter the following lines.

sudo apt-get update

sudo apt-get install mono-runtime

As mentioned in other tutorials the first line is used to update the APT-GET package manager to ensure it is using the latest sources for downloading your packages. The second line installs and prepares the runtimes for use. That's it, now to run a Mono developed EXE file. Just simply prefix the command with the word mono as shown below.

mono myprogram.exe 
S_BatMan
  • 505
  • 6
  • 13
  • How would you characterize the performance of the mono apps on the Raspberry? Would you say, it's good enough for real world applications (like maybe an embedded device or a real-time processing device)? – AngryHacker Jul 05 '12 at 17:20
  • @AngryHacker Overall I would say good for its price. Its not a super stable microcontroller that should be trusted for data/time critical operations. and it may lack the power due to its parts (price) to be used for anything substantial, but as a test base/framework, or as an initial prototyping framework its fantastic. Its designed to teach and its hardware reflects that. For field use, other options will be better. – S_BatMan Jul 06 '12 at 23:15
  • Can I use MonoDevelop on Windows 7 to develop/compile/test my application and then transfer it to my Raspberry PI afterwards or would I need to move the sourcefiles and compile on the device directly? I was thinking of transfering files over LAN... just make the bin folder public on LAN .. – BerggreenDK Feb 21 '13 at 14:59
  • In all honesty it isnt something that i have tried, However due to the natue for the JIT then yes this should be completly possible. Infact assuming it dosnt use any functionality that isnt avaliable in the mono version on the pi you should be able to run any mono exe – S_BatMan Mar 05 '13 at 07:45
6

Yes. I've successfully run Mono based Winforms and Webforms apps (XSP). Detailed How to is available in my blog

http://www.amazedsaint.com/2013/04/hack-raspberry-pi-how-to-build.html

amazedsaint
  • 7,642
  • 7
  • 54
  • 83
5

Hard float support is now in mono 3.2.7:
http://www.raspberrypi.org/phpBB3/viewtopic.php?t=62496&p=468500

The latest source can be installed from git. It should be something like this:
(remove previous mono installations first)

sudo apt-get update
sudo apt-get install git build-essential automake autoconf libtool gettext
git clone git://github.com/mono/mono.git
cd mono
./autogen.sh --prefix=/usr/local
make get-monolite-latest
make EXTERNAL_MCS="${PWD}/mcs/class/lib/monolite/gmcs.exe"
sudo make install

This is how "mono -V" looks like on my raspberry:

Mono JIT compiler version 3.4.0 (master/ae165c5 Thu Mar 13 01:20:37 UTC 2014)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
    TLS:           __thread
    SIGSEGV:       normal
    Notifications: epoll
    Architecture:  armel,vfp+hard
    Disabled:      none
    Misc:          softdebug
    LLVM:          supported, not enabled.
    GC:            sgen

A quick test seems to work fine:

csharp> Math.Pow(2,4);
16
roeland
  • 6,058
  • 7
  • 50
  • 67
4

On my Raspberry Pi running the Fedora 18 remix, all I needed was:

    # yum -y install mono-devel

To Check:

    # csharp
    Mono C# Shell, type "help;" for help
    Enter statements below.
    csharp> Console.WriteLine("Hello, I am PI");
    Hello, I am PI
    csharp>  
  • 6
    You should add to your check: "Math.Pow(2,4);". If this returns 16, you're good. If it returns garbage, you've run into the bug in Mono on ARM Linux distros that use the hard-float ABI. – Joe Strout Mar 11 '13 at 15:17
1

I was able to run my .NET exe on raspberry pi (debian).

Install mono - http://logicalgenetics.com/raspberry-pi-and-mono-hello-world/

then run your exe as mono something.exe

Rolwin Crasta
  • 4,219
  • 3
  • 35
  • 45
1

You can run x86 version of Mono on Raspberry Pi using ExaGear Desktop software.

It allow to run almost all x86 apps and even install Wine to run Windows apps.

They say that Firefox works faster than even native ...