MonoDevelop C# on RPI (or Visual Studio for Linux)


31 posts   Page 1 of 2   1, 2
by melikescheese » Wed Jun 06, 2012 11:22 am
After reading a previous post about mono on arch I set out to achieve the same on my debian rpi, so here's a step by step guide to installing mono and monodevelop (The linux answer to Visual Studio) on debian. ;) EDIT: MonoDevelop is reaaaaalllllyyyy slow unless you're prepared for a really slow user experiance just install mono; do the following steps without the apt-get monodevelop step.

1 (Optional). I'd advise expanding your SD card if it's over 2GB to provide a little more space for install I won't tell you how to do that here but here's a link to the video I used. http://www.youtube.com/watch?v=R4VovMDnsIE
2. Open a terminal instance
3. Type the following commands
sudo apt-get update
sudo apt-get install mono-runtime
sudo apt-get install monodevelop

4. To start monodevelop go to Programming -> MonoDevelop in the LXDE menu.
5. Happy C# developing!

P.S If this doesn't work for you please tell me what error you get below and i'll try to revise this ASAP
User avatar
Posts: 16
Joined: Sat Mar 03, 2012 1:06 pm
by JohnStabler » Sat Jun 09, 2012 4:49 pm
Yes MonoDevelop is so slow as to be unusable. I've been developing on another machine. I tried using xbuild on the project files but got a task error.

Manually built the project with gmcs in the end.

If you just want a code editor for C# then geany is an option.
John Stabler MBCS - Veteran Computer Programmer
Posts: 6
Joined: Sat Jun 09, 2012 4:27 pm
by rodonn » Sat Jun 16, 2012 1:48 pm
Done a little playing, and you can get a fair turn of speed if you use IceWM, wmaker or Blackbox as the WM for Monodevelop.

My criteria were
1) no menu fiddling. If the WM didn't pick up LXDE .desktop files it was game over
2) Acceptable speed
3) Acceptable stability.
NOTE - 2 and 3 are obviously subjective, so other users' mileage may vary on how well I've selected.


I started from this post http://www.raspberrypi.org/phpBB3/viewtopic.php?f=63&t=7571 and then winged it from the f1 alternate sessions listed in SLiM (I know, SLiM is for the weak, but idleness is nothing if not worked at... if you want the CLI login press Ctrl-Alt F<pick an number between 1 and 6> and you will receive ;) )

For completeness, I tested
LXDE - geologically slow, and could crash the RPi completely. Could have been a long time out, but the clock wasn't updating, and after 15 mins I called it 'crashed'.
XFCE - a little faster than LXDE but also crashed the whole machine, more or less the same as LXDE
Openbox - it may run but needs to be messed with for menus to reflect what's installed.The rest seems sprightly. I didn't look further.
IceWM - closest to LXDE in look and feel, but it works fast, when it works. At least only the application crashed rather than it taking out the RPi, and after a couple of reloads, it didn't happen again.
WMaker - works in a usable fashion, but is a little ugly IMO.
Blackbox - my personal favourite, but not LXDE look and feel.
Awesome - it looked usable enough, but didn't pick up the Programming applications and the text seemed to be the wrong size for the menus. GUI seems responsive. I didn't fiddle further.
Conclusion.
I had a couple of crashes in IceWM, I didn't like the feel of wmaker, and so have decided to go to Blackbox, at least for the moment.
Posts: 12
Joined: Mon May 28, 2012 4:00 pm
by JohnStabler » Wed Jun 20, 2012 11:31 am
I'm wondering if once hardware acceleration is available that MonoDevelop will be usable on LXDE or whether it's simply a case of not enough memory on the Pi?
John Stabler MBCS - Veteran Computer Programmer
Posts: 6
Joined: Sat Jun 09, 2012 4:27 pm
by jeeshenlee » Tue Jul 17, 2012 2:39 am
I have ordered my RPi but i can't wait to find out, is it possible to MonoDevelop C# on PC? If yes, how do i deployed the developed app on RPi? Copy to SD card? Thanks!
Posts: 2
Joined: Tue Jul 17, 2012 2:29 am
by JohnStabler » Tue Jul 17, 2012 8:22 am
jeeshenlee wrote:I have ordered my RPi but i can't wait to find out, is it possible to MonoDevelop C# on PC? If yes, how do i deployed the developed app on RPi? Copy to SD card? Thanks!

You can build Mono applications on another machine (like a Windows PC), as long as the build options are set to produce platofrm independent IL code and then simply copy the EXE file. If you have dependencies other the Mono framework which are platform dependent then you may have to copy the project to the Pi and build on the command line with the linux versions of the libraries.

I don't think it's a simple case of copying file(s) to the SD card. You'll probably find the best solution is to install the samba client and then access a shared folder over the network.
John Stabler MBCS - Veteran Computer Programmer
Posts: 6
Joined: Sat Jun 09, 2012 4:27 pm
by mikeparris » Wed Aug 01, 2012 4:41 pm
Hi I have installed a copy of the Raspbian "wheezy" image and then followed the instructions of melikeschees to installed mono-runtime and monodevelop but get a failure when starting monodevelop from the LXDE menu.

The splash screen shows for about 15 seconds and then the error panel appears with - "MonoDevelop failed to start. The following error has been reported: Object reference not set to an instance of an object"

Detail is -
"System.NullReferenceException: Object reference not set to an instance of an object
at MonoDevelop.Ide.IdePreferences.get_DefaultTargetRuntime () [0x00000] in <filename unknown>:0
at MonoDevelop.Ide.RootWorkspace.set_UseDefaultRuntime (Boolean value) [0x00000] in <filename unknown>:0
at MonoDevelop.Ide.RootWorkspace..ctor () [0x00000] in <filename unknown>:0
at MonoDevelop.Ide.IdeApp.Initialize (IProgressMonitor monitor) [0x00000] in <filename unknown>:0
at MonoDevelop.Ide.IdeStartup.Run (MonoDevelop.Ide.MonoDevelopOptions options) [0x00000] in <filename unknown>:0"

Anyone got a pointer to whats wrong or how to diagnose?
Posts: 7
Joined: Wed Aug 01, 2012 4:29 pm
by AndiDog » Sat Aug 04, 2012 9:59 pm
I'm having the same problem. Had it working on Debian squeeze when I compiled Mono and MonoDevelop myself, but I won't go that path again (took more than one day). mdtool also doesn't work anymore for me.
Posts: 28
Joined: Sat Apr 07, 2012 6:01 pm
by luisgp82 » Tue Aug 07, 2012 8:06 am
I'm having the same problem. :(
Heeeeelp :cry:
User avatar
Posts: 3
Joined: Fri Jul 20, 2012 6:38 am
by popadrian » Mon Aug 13, 2012 1:30 pm
If I start monodevelop from Programming -> MonoDevelop i get the same error as "mikeparris".
If I try to open a cs file, it is open with monodevelop and for me it seems to work; I don't get the error.
Posts: 1
Joined: Mon Aug 13, 2012 1:29 pm
by amigarulez » Mon Aug 13, 2012 2:13 pm
[quote="mikeparris"]Hi I have installed a copy of the Raspbian "wheezy" image and then followed the instructions of melikeschees to installed mono-runtime and monodevelop but get a failure when starting monodevelop from the LXDE menu.[/quote]
Raspbian “wheezy” / hard float issues with mono aren't solved yet(or are they?)
So basically any floating point operation can give errors / fail until issues are fixed.
Posts: 42
Joined: Wed Jul 18, 2012 10:16 am
by melikescheese » Tue Aug 14, 2012 1:40 pm
I'm glad to see people using my guide, however I need to add that I made the instructions under the old Debian distro (not raspbian) so I'm gonna guess that until there is a Raspbian update to fix the bugs then Mono won't work on it. If you really want mono just use the old debian release till then, I'll try and use the above suggestions to get a workable MonoDevelop instance on it. I also overclocked my pi to 900Mhz to make it a little faster.
User avatar
Posts: 16
Joined: Sat Mar 03, 2012 1:06 pm
by melikescheese » Tue Aug 14, 2012 1:45 pm
jeeshenlee wrote:I have ordered my RPi but i can't wait to find out, is it possible to MonoDevelop C# on PC? If yes, how do i deployed the developed app on RPi? Copy to SD card? Thanks!


Personally if you are looking to develop C# on windows then you I would use Visual Studio 2010 C# Express edition. All of the compiled .net applications work on mono. I love intellisense and it is the best C# IDE around IMO.
User avatar
Posts: 16
Joined: Sat Mar 03, 2012 1:06 pm
by jeeshenlee » Wed Aug 15, 2012 6:42 am
@melikescheese, thanks. I got my raspberry pi now and tried C# development with Mono and chunk out some helloworls apps, so far so good. :D

That brings me to another questions, what is the recommended UI framework for C# mono developers? I knew WPF is not possible and i'm looking at Qt and WinForm now.
Posts: 2
Joined: Tue Jul 17, 2012 2:29 am
by amigarulez » Wed Aug 15, 2012 10:11 am
jeeshenlee wrote:That brings me to another questions, what is the recommended UI framework for C# mono developers? I knew WPF is not possible and i'm looking at Qt and WinForm now.

Probably most stable solution is GTK.
Posts: 42
Joined: Wed Jul 18, 2012 10:16 am
by melikescheese » Wed Aug 15, 2012 11:03 am
I'd say your best bet would be GTK as it's cross platform (think GIMP on Windows, Linux, etc) However if you want the best results to be on Windows with a not so perfect Linux build then use WinForms, also it's the one that is integrated into Visual Studio and the official C# preferred framework.

Glad you've finally got your raspberry pi, I've only just recommenced work on mine after finding a decent power supply :) I followed the instructions of rodonn on my Wheezy soft-float installation and like him I preffer blackbox for a better experience.
User avatar
Posts: 16
Joined: Sat Mar 03, 2012 1:06 pm
by arti0504 » Wed Jan 30, 2013 9:07 am
Hi I have installed a copy of the Raspbian "wheezy" image and then followed the instructions of melikeschees to installed mono-runtime and monodevelop but get a failure when starting monodevelop from the LXDE menu.

The splash screen shows for about 15 seconds and then the error panel appears with - "MonoDevelop failed to start. The following error has been reported: Object reference not set to an instance of an object"

Detail is -
"System.NullReferenceException: Object reference not set to an instance of an object
at MonoDevelop.Ide.IdePreferences.get_DefaultTargetRuntime () [0x00000] in <filename unknown>:0
at MonoDevelop.Ide.RootWorkspace.set_UseDefaultRuntime (Boolean value) [0x00000] in <filename unknown>:0
at MonoDevelop.Ide.RootWorkspace..ctor () [0x00000] in <filename unknown>:0
at MonoDevelop.Ide.IdeApp.Initialize (IProgressMonitor monitor) [0x00000] in <filename unknown>:0
at MonoDevelop.Ide.IdeStartup.Run (MonoDevelop.Ide.MonoDevelopOptions options) [0x00000] in <filename unknown>:0"

Anyone got a pointer to whats wrong or how to diagnose?
Posts: 18
Joined: Wed Jan 30, 2013 8:40 am
by 3gws » Wed Jan 30, 2013 2:31 pm
Which Raspian Wheezy version did you install it on ?

See here, might be of help to you.

viewtopic.php?f=66&t=11634&hilit=raspian+vs+wheezy+beta+mono+support
Posts: 49
Joined: Sat Oct 20, 2012 10:32 am
by bfagioli » Thu Jan 31, 2013 2:23 am
Same results for me. I'm using 2012-12-16-wheezy-raspbian (aka "hard float"). There are many known issues with the Mono runtime on this hard float distro. The other thread that the previous reply references seems to offer hope. Many of us are waiting for an updated release of mono (v3.0?) that supports hard-float better. Maybe that update will also provide a working monodevelop. However, I probably wont use monodevelop since I happy using Microsoft Visual Studio Express (free) on my PC for development and a shared folder to my RPi to run my code. I had never even run monodevelop on the RPi unto just now but I do see the exact same failure.
User avatar
Posts: 113
Joined: Sat Oct 27, 2012 11:49 pm
by melikescheese » Thu Jan 31, 2013 7:59 pm
Mono does not work on Hard Float.

Mono does work on Soft Float.

I would reason that MonoDevelop will work better on the 512MB RAM RasPi, but only if you use an old soft float build of debian. However somebody somewhere should be working on Mono for hard float as RasPi is a VERY large installed base of hardware to deploy to.
User avatar
Posts: 16
Joined: Sat Mar 03, 2012 1:06 pm
by arti0504 » Tue Mar 05, 2013 11:38 pm
Hello,

I have this code:

// helloworld.cs - Gtk# Tutorial example

using Gtk;
using GtkSharp;
using System;
using System.Drawing;

public class HelloWorld {
// This is a callback function. The data arguments are ignored
// in this example. More on callbacks below.
static void hello (object obj, EventArgs args)
{
Console.WriteLine("Hello World");
Application.Quit ();
}

static void delete_event (object obj, DeleteEventArgs args)
{
// If you return FALSE in the "delete_event" signal handler,
// GTK will emit the "destroy" signal. Returning TRUE means
// you don't want the window to be destroyed.
// This is useful for popping up 'are you sure you want to quit?'
// type dialogs.

Console.WriteLine ("delete event occurred\n");
Application.Quit ();
}

public static void Main(string[] args)
{
// This is called in all GTK applications. Arguments are parsed
// from the command line and are returned to the application. */
Application.Init ();

// create a new window
Window window = new Window ("helloworld");

// When the window is given the "delete_event" signal (this is given
// by the window manager, usually by the "close" option, or on the
// titlebar), we ask it to call the delete_event () function
// as defined above. The data passed to the callback
// function is NULL and is ignored in the callback function.

window.DeleteEvent += new DeleteEventHandler (delete_event);

// Sets the border width of the window.
window.BorderWidth = 10;

// Creates a new button with the label "Hello World".
Button btn = new Button ("Hello World");

// When the button receives the "clicked" signal, it will call the
// function hello() passing it null as its argument. The hello()
// function is defined above.
btn.Clicked += new EventHandler (hello);

// This packs the button into the window (a gtk container).
window.Add (btn);

// The final step is to display this newly created
window.ShowAll ();

// All GTK applications must call the main loop: Application.Run
// Events are processed and dispatched here.

Application.Run ();
}
}

I would like compile, so I write in console:
mcs hw.cs

then I have 4 error:

could not found 'Gtk' 'GtkSharp' 'SystemDrawing' 'DeleteEventArgs'
try using -pkg:gtk-sharp

How can I fix it?
Posts: 18
Joined: Wed Jan 30, 2013 8:40 am
by amigarulez » Wed Mar 06, 2013 11:08 am
arti0504 wrote:I would like compile, so I write in console:
mcs hw.cs

then I have 4 error:

could not found 'Gtk' 'GtkSharp' 'SystemDrawing' 'DeleteEventArgs'
try using -pkg:gtk-sharp

How can I fix it?


gtk-sharp-2 package must be installed (on Arch Linuc done via "pacman -S gtk-sharp-2")

If installed you specify that package to the compiler i.e:
mcs -pkg:gtk-sharp-2.0 hw.cs

You can specify individual assmblies can be referenced like this
mcs -r:/usr/local/lib/mono/gtk-sharp-2.0/glib-sharp.dll hw.cs
Posts: 42
Joined: Wed Jul 18, 2012 10:16 am
by arti0504 » Wed Mar 06, 2013 9:45 pm
I have install gtk-sharp-2 library.

I use this code form this website http://mono-project.com/Mono_Basics

using Gtk;
using System;

class Hello {

static void Main()
{
Application.Init ();

Window window = new Window ("helloworld");
window.Show();

Application.Run ();

}
}

I would like compile and run. I have this error:

pi@raspberrypi ~/Projekty/C#/hello $ gmcs new2.cs -pkg:gtk-sharp-2.0
pi@raspberrypi ~/Projekty/C#/hello $ mono new2.exe
Missing method System.Type::op_Inequality(Type,Type) in assembly /usr/lib/mono/2.0/mscorlib.dll, referenced in assembly /usr/lib/mono/gac/gtk-sharp/2.12.0.0__35e10195dab3c99f/gtk-sharp.dll

Unhandled Exception: System.MissingMethodException: Method not found: 'System.Type.op_Inequality'.
at Gtk.Window..ctor (System.String title) [0x00000] in <filename unknown>:0
at Hello.Main () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.MissingMethodException: Method not found: 'System.Type.op_Inequality'.
at Gtk.Window..ctor (System.String title) [0x00000] in <filename unknown>:0
at Hello.Main () [0x00000] in <filename unknown>:0

I must install something else or I must change something?
Posts: 18
Joined: Wed Jan 30, 2013 8:40 am
by JoeStrout » Sun Mar 10, 2013 2:13 pm
I'd just like to share my excitement — I installed mono-complete on my Raspian (1st-generation) RPi yesterday, and it appears to work great! I quickly got it talking to the serial port, and will have it driving around robots as soon as my level shifter arrives.

I personally don't care much about MonoDevelop; I mostly connect to my RPi over ssh anyway, so I'm happy using a text editor and compiling on the command line. Or, for quick hacks, I just use the csharp interactive environment.

I think we should start advocating this as an alternative to Python... I probably don't need to explain to folks in this thread why C# is a great choice in general.

One question, though, as I'm still pretty new to C# (and especially to using it on RPi): what would be the best library for making 2D, PyGame-style games in C# on the RPi?
Posts: 41
Joined: Sun Oct 09, 2011 12:11 pm
by bfagioli » Tue Mar 12, 2013 1:19 pm
JoeStrout, I'm glad you are finding success using C# / Mono on your Raspbian hardfp distro. I want to caution you though that Mono has some very serious problems on Raspbian. Anything that uses floating point libraries will not work correctly. As a very simple example try printing System.DateTime.Now() and see what you get. Not good. There was some hope that a working version of Mono would become available at the beginning of this year but months have gone by with no news so this seems unlikely to me. If you want a fully working Mono you need to use softfp Debian "wheezy". Because the Foundations recommends Raspian and because Mono is seriously broken on that distro I think Mono should not be recommended to any beginners -- not until its working correctly.
User avatar
Posts: 113
Joined: Sat Oct 27, 2012 11:49 pm