43

Is it possible (and feasible) to run .NET applications on the Raspberry Pi with Mono?

If so, how well do they run? Is a basic GUI usable, or does poor performance realistically restrict it to command line applications?

Alex Chamberlain
  • 15,530
  • 14
  • 67
  • 113
berry120
  • 10,924
  • 10
  • 51
  • 62

4 Answers4

27

There is a StackOverflow question quite similar to this, Mono on Raspberry Pi. However, through my own research, I haven't been able to find anything specific to .NET, but rather just C#.

You can install the runtime using APT on a Debian distro by executing:

$ sudo apt-get install mono-runtime

You can also (assuming you have some sort of GUI such as LXDE) install a slow Mono IDE with:

$ sudo apt-get install monodevelop

For Arch Linux ARM you need to install the runtime via Pacman, like so:

$ sudo pacman -S mono

The Mono IDE can be installed in a similar fashion:

$ sudo pacman -S monodevelop
Andrew Larsson
  • 1,614
  • 17
  • 22
  • 1
    What do you mean by "rather to just C#"? – Jon Egerton Jul 16 '12 at 08:09
  • @JonEgerton C# is a language while .NET is a framework. You can develop for the .NET framework with C#, but C# can stand alone as an independent programming language. A more relatable example might be: you develop for Android with Java, but you can write a desktop program with Java. C# does not depend on .NET, but .NET depends on C#. – Andrew Larsson Jul 16 '12 at 18:12
  • Hi sorry, that's not what I meant (I'm a .Net dev!!). It was more the exclusivity of C# and not the other .net family languages (vb.net, J# F# etc). I've never looked into Mono, and hadn't realised it is C# only. – Jon Egerton Jul 16 '12 at 21:31
  • Oh, I see what you're saying. I was only trying to find things on C# and .NET and hadn't really considered checking the other .NET languages. From what I remember, and from all the forum threads that I read, I didn't see any interest in developers trying to get those on the RPi. – Andrew Larsson Jul 18 '12 at 16:51
  • 5
    @Andrew It’s the other way round: .NET doesn’t depend on C# – but C# does depend on a runtime such as .NET (or Mono), it’s never in practice an independent programming language. Furthermore, mono is totally language agnostic (as is .NET), so once again it doesn’t depend on C#. – Konrad Rudolph Aug 05 '12 at 16:31
  • That's true, but being a framework implies that it's tied to a language. It can be ported/rewritten as a different implementation in a different language, so perhaps "tied" is a little too strong of a word for me to have used. – Andrew Larsson Aug 05 '12 at 23:49
  • 1
    Dont install MonoDeveloper on the device. Thats waaaay to slow. Just mount a networkdrive with CIFS and compile on a fast PC/MAC and then test-run over LAN. – BerggreenDK Feb 24 '13 at 01:56
  • @BerggreenDK Great idea. I'll accept your edit if you modify the answer to include that. – Andrew Larsson Feb 25 '13 at 17:56
  • @AndrewLarsson - I dont have edit rights in this part of StackoverFlow yet. But just mount a CIFS drive. its pretty streight forward. The FAQ on the website even tells how. – BerggreenDK Feb 25 '13 at 21:27
  • @AndrewLarsson - Actually my idea isnt really mine, my developer skills comes from back in time with Commodore 64 and Amiga, where we could cross-compile on bigger hardware to be able to have better speeds when testing.

    So its nothing new, its merly: "Dont work harder, work smarter" :-)

    – BerggreenDK Feb 25 '13 at 21:29
8

Contrary to popular belief, VB.NET compiled code runs fine on the Raspberry Pi, under Debian at least. apt-get install mono-vbnc and then run your VB exe as an argument to mono e.g. mono yourexe.exe

I haven't done any performance benchmarks as I am not writing a performance intensive app but seems fine so far.

Guy
  • 1,657
  • 1
  • 16
  • 18
  • any .NET language compiles into the same IL/Bytecode, so once you trigger the compiler (mono-vbnc or whatever language), your VB is gone and the IL is the thing used in the RUNTIME core. – BerggreenDK Feb 24 '13 at 01:58
6

.NET code which is using .NET Framework libraries can't run on Raspberry Pi as it requires an ARM compatible version of NETMF or CLR to run. As of now, Microsoft has yet to release Windows on ARM (WoA). Refer to Experiment 19 for Microsoft Research CLR works on ARM.

However, running .NET code (without reference or using .NET Framework Libraries) is possible using Mono as Mono has a CLR for ARM devices.

See also Building Windows for the ARM processor architecture for information on Windows on ARM (WoA).

Glorfindel
  • 620
  • 1
  • 8
  • 15
JeeShen Lee
  • 1,405
  • 2
  • 10
  • 10
  • 3
    I think your statement is wrong here. It is possible to copy an .EXE file which was compiled on the PC which references and uses .NET framework classes (e.g. the Socket class or TcpListener class for example), copy it over unchanged to the RPi, and have it run perfectly on the RPi under Mono. This is because Mono replaces most of the .NET framework base classes with its own version, using exactly the same namespaces, types and interfaces. – dodgy_coder Sep 11 '12 at 05:31
4

I've got a command line .NET application to work with Mono. The app is basically doing something akin to port forwarding, taking data received via the serial UART and forwarding it over TCP/IP. It uses the SerialPort, TcpListener, TcpClient and Socket .NET classes, with only minor changes needed to the SerialPort handling code. I'm using the Debian soft float OS.

In terms of performance, the first thing that I came across was some significant slowdowns in some debugging/trace code which was formatting an array of bytes into a string for logging purposes. It was 50x slower compared to running on a PC.

So I'd recommend writing some performance unit tests when porting existing code to the RPi.

For unit testing, NUnit works fine on the RPi...

To install NUnit:

sudo apt-get install nunit

To run:

nunit-console appUnderTest.exe
dodgy_coder
  • 140
  • 4
  • 1
    Speed is a relative thing. But a Raspberry PI running at 1000 mhz (model 2) performs approx like a Pentium 300 mhz, so that might explain why .NET/MONO feels rather slow for a start. – BerggreenDK Feb 24 '13 at 02:00