moelski
Posts: 63
Joined: Wed Jan 09, 2013 8:16 am

Tutorial : Install / Compile Mono

Sun Aug 31, 2014 4:52 am

Hi @all,

since I´m a big fan of C# and Mono I have written some documentation how to install / compile this stuff.
The document is for Raspberry (ARM6), Cubietruck (ARM7), Lubuntu (Debian) and Centos (RadHat).
It covers these 3 topics for all systems (except Centos):
* Installing
* Compiling from TAR
* Compiling from GIT

Some note about Raspberry Pi and Mono ...
If you compile Mono from GIT on your Pi you will be able to run WinForms applications as well. See the attached screenshot for a visual impression 8-)

Download
You can get the PDF document here:
http://logview.info/forum/index.php?res ... th-mono.7/

If you have any comments or suggestions please let me know.

Dominik
http://www.logview.info
Attachments
WinForms Screen.jpg
Raspberry running a winForms App with interesting visuals ...
WinForms Screen.jpg (62.76 KiB) Viewed 10670 times
Last edited by moelski on Tue Sep 16, 2014 8:35 pm, edited 1 time in total.

janith
Posts: 6
Joined: Tue Sep 02, 2014 5:02 am

Re: Manual : Install / Compile Mono

Wed Sep 03, 2014 6:00 am

Hi moelski,
Nice to see you get windows.forms working. I am having also trying to make it work. My very simple Windows.Forms application that has only a form without any TextBoxs or Buttons. does not run at all. It compiles but in runtime gives Errors. First I tried with ubuntu 3.2.8 and then install ubuntu 3.8.1 from source following your guide. Is theres something I am missing. Really appriciate if you can help on this.
The errors I am getting are,
Unhandled Exception:
System.ArgumentException: A null reference or invalid value was found [GDI+ status: InvalidParameter]
at System.Drawing.GDIPlus.CheckStatus (Status status) [0x00000] in <filename unknown>:0
FATAL UNHANDLED EXCEPTION: System.ArgumentException: A null reference or invalid value was found [GDI+ status: InvalidParameter]
at System.Drawing.GDIPlus.CheckStatus (Status status) [0x00000] in <filename unknown>:0

moelski
Posts: 63
Joined: Wed Jan 09, 2013 8:16 am

Re: Manual : Install / Compile Mono

Wed Sep 03, 2014 6:03 am

Can you attach your Project here as a ZIP?
So I can check it.

Dominik

janith
Posts: 6
Joined: Tue Sep 02, 2014 5:02 am

Re: Manual : Install / Compile Mono

Wed Sep 03, 2014 7:14 am

Hi,
this is the simple code I tried to execute, it compile and run on PC, compile on armhf but do not execute.
using System;
using System.Drawing;
using System.Windows.Forms;

public class HelloWorld : Form
{
static public void Main ()
{
Application.Run (new HelloWorld ());
}

public HelloWorld ()
{
Button b = new Button ();
b.Text = "Click Me!";
b.Click += new EventHandler (Button_Click);
Controls.Add (b);
}

private void Button_Click (object sender, EventArgs e)
{
MessageBox.Show ("Button Clicked!");
}
}

emg
Posts: 88
Joined: Wed Jan 11, 2012 11:01 pm

Re: Manual : Install / Compile Mono

Wed Sep 03, 2014 7:27 am

Uhh, that screenshot is from a Windows 7 PC...?

moelski
Posts: 63
Joined: Wed Jan 09, 2013 8:16 am

Re: Manual : Install / Compile Mono

Wed Sep 03, 2014 10:07 am

Hi !
Uhh, that screenshot is from a Windows 7 PC...?
Yes and No.
The screen is on Windows 7 using a X Server. So only the output is drawn on Windows. The Program runs on the raspberry 8-)
this is the simple code I tried to execute
Ok, I made a textfile "source.cs" and placed your code within the file.
Then I run this on my Pi:

Code: Select all

gmcs -r:System.Windows.Forms.dll -r:System.Drawing.dll source.cs
It compiles fine without any issues.

After starting the resultuing executable I got the attached output. (Again I am using an X Server to get the Pi output on my windows system ... )

For me it looks like you missed compile / install the libgdiplus part. Or something went wrong with that compilation.
You could check the debug output to get in better understanding what went wrong.
Just run your exe with the MONO_LOG_LEVEL=debug option:

Code: Select all

MONO_LOG_LEVEL=debug mono source.exe
It will produce a lot output in the console but at the end it show up some more details ...

Dominik
Attachments
output.jpg
output.jpg (8.83 KiB) Viewed 10494 times

janith
Posts: 6
Joined: Tue Sep 02, 2014 5:02 am

Re: Manual : Install / Compile Mono

Wed Sep 03, 2014 11:52 am

thank you for your help, I ran the program with the Parameter set as you have suggested. Do you have any sugestions. I found libgdilplus.so install usr/lib Folder.
Real appreciate your help on this.
Attachments
error.rar
Error log
(3.29 KiB) Downloaded 205 times

moelski
Posts: 63
Joined: Wed Jan 09, 2013 8:16 am

Re: Manual : Install / Compile Mono

Wed Sep 03, 2014 12:03 pm

Hi !

Well that error was reported in the Mono bug list. But actually there is no solution.

Which System are you running? Is it raspbian? And which local are you using?

janith
Posts: 6
Joined: Tue Sep 02, 2014 5:02 am

Re: Manual : Install / Compile Mono

Thu Sep 04, 2014 3:29 am

I am actualy using the beaglebone black with ubuntu and my mono Version is exactly same as yours.

janith
Posts: 6
Joined: Tue Sep 02, 2014 5:02 am

Re: Manual : Install / Compile Mono

Thu Sep 04, 2014 4:33 am

Hello moelski,
I have seen bug reports on TextBox failing but they were able to run simple Windows form without TextBox. I have not being able to run even the Basic form. Have you seen this as bug Report. May be it is not observed in Raspberry pi.

FilipeAraujo
Posts: 3
Joined: Fri Sep 05, 2014 8:39 am

Re: Manual : Install / Compile Mono

Fri Sep 05, 2014 8:47 am

Hello moelski,

I installed mono using your guide, but its still not working, the window still crashes. im trying to run a .exe file i compiled in windows. Do i have to compile it using gmcs? when i tried to do it i had to add several .dll files and i still get 2 errors while compiling and no idea what to add to compile this with no errors.

The errors in compilation are about the missing Assembly reference, but i have no more .dll files to refer to.

any thoughts? (Sry for bad english btw :) )

moelski
Posts: 63
Joined: Wed Jan 09, 2013 8:16 am

Re: Manual : Install / Compile Mono

Sun Sep 07, 2014 8:52 am

Hi !
using the beaglebone black with ubuntu
Well I don´t own a BeagleBone. So at the moment it´s hard for me to do some testing.

If you look at your logging you see that the last library is libx11.so.6. So I have only some ideas what could be the main Problem:
* Is your X11 System installed correctly? (On the Pi and Cubie this is installed by Default.)
* If you connect throug SSH and try to run the app it could be a Problem that you don´t have an X Server running. Or you miss to configure the DISPLAY variable?
im trying to run a .exe file i compiled in windows. Do i have to compile it using gmcs?

I compiled my test application in Windows 7 64Bit with VS 2012. So NO you don't Need to use GMCS. But it would work using this command:

Code: Select all

gmcs -r:System.Windows.Forms.dll -r:System.Drawing.dll source.cs
If you have a Basic forms application this should work fine.
when i tried to do it i had to add several .dll files and i still get 2 errors while compiling and no idea what to add to compile this with no errors.
Well my bead is still in repair ... Some Log Information would be nice to give some advice ... ;)

Dominik

FilipeAraujo
Posts: 3
Joined: Fri Sep 05, 2014 8:39 am

Re: Manual : Install / Compile Mono

Fri Sep 12, 2014 4:10 pm

I manage to compile my code with no errors, but while executing i got the following:


(mono:3123): GLib-GObject-WARNING **: Attempt to add property GtkSettings::gtk-can-change-accels after class was initialised

(mono:3123): GLib-GObject-WARNING **: Attempt to add property GtkSettings::gtk-menu-popup-delay after class was initialised

(mono:3123): GLib-GObject-WARNING **: Attempt to add property GtkSettings::gtk-menu-popdown-delay after class was initialised
* Assertion at mini-codegen.c:807, condition `i == sel' not met

Stacktrace:

at <unknown> <0xffffffff>
at System.Windows.Forms.TextBoxBase.Draw (System.Drawing.Graphics,System.Drawing.Rectangle) <IL 0x00015, 0x000b3>
at System.Windows.Forms.TextBoxBase.OnPaintInternal (System.Windows.Forms.PaintEventArgs) <IL 0x0000d, 0x00063>
at System.Windows.Forms.Control.WmPaint (System.Windows.Forms.Message&) <IL 0x0007a, 0x0017f>
at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message&) <IL 0x00161, 0x00223>
at System.Windows.Forms.TextBoxBase.WndProc (System.Windows.Forms.Message&) <IL 0x00211, 0x0032b>
at System.Windows.Forms.TextBox.WndProc (System.Windows.Forms.Message&) <IL 0x00177, 0x001db>
at System.Windows.Forms.Control/ControlWindowTarget.OnMessage (System.Windows.Forms.Message&) <IL 0x00007, 0x0002b>
at System.Windows.Forms.Control/ControlNativeWindow.WndProc (System.Windows.Forms.Message&) <IL 0x0000c, 0x0003b>
at System.Windows.Forms.NativeWindow.WndProc (intptr,System.Windows.Forms.Msg,intptr,intptr) <IL 0x00091, 0x002e7>
at System.Windows.Forms.XplatUIX11.DispatchMessage (System.Windows.Forms.MSG&) <IL 0x00018, 0x00023>
at System.Windows.Forms.XplatUI.DispatchMessage (System.Windows.Forms.MSG&) <IL 0x00006, 0x00033>
at System.Windows.Forms.Application.RunLoop (bool,System.Windows.Forms.ApplicationContext) <IL 0x0036e, 0x00bd7>
at System.Windows.Forms.Application.Run (System.Windows.Forms.ApplicationContext) <IL 0x00016, 0x00067>
at System.Windows.Forms.Application.Run (System.Windows.Forms.Form) <IL 0x00006, 0x00033>
at UniversalGateway.Main (string[]) [0x000a2] in /home/pi/Desktop/UniversalGateway/Universal Gateway.cs:223
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>

Native stacktrace:


Debug info from gdb:

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
[New Thread 0xb5c03430 (LWP 3126)]
0xb6f1ba3c in waitpid () from /lib/arm-linux-gnueabihf/libpthread.so.0
Id Target Id Frame
2 Thread 0xb5c03430 (LWP 3126) "mono" 0xb6f19700 in [email protected]@GLIBC_2.4 () from /lib/arm-linux-gnueabihf/libpthread.so.0
* 1 Thread 0xb6fef000 (LWP 3123) "mono" 0xb6f1ba3c in waitpid () from /lib/arm-linux-gnueabihf/libpthread.so.0

Thread 2 (Thread 0xb5c03430 (LWP 3126)):
#0 0xb6f19700 in [email protected]@GLIBC_2.4 () from /lib/arm-linux-gnueabihf/libpthread.so.0
#1 0x001fff10 in mono_sem_wait (sem=0x2f523c, alertable=1) at mono-semaphore.c:119
#2 0x0017db28 in finalizer_thread (unused=<optimized out>) at gc.c:1073
#3 0x001625b4 in start_wrapper_internal (data=0x1a4b350) at threads.c:643
#4 start_wrapper (data=0x1a4b350) at threads.c:688
#5 0x001f5c30 in thread_start_routine (args=0x19f9f30) at wthreads.c:294
#6 0x00204268 in inner_start_thread (arg=0x19f9f24) at mono-threads-posix.c:49
#7 0xb6f12bfc in start_thread () from /lib/arm-linux-gnueabihf/libpthread.so.0
#8 0xb6e7f968 in ?? () from /lib/arm-linux-gnueabihf/libc.so.6
#9 0xb6e7f968 in ?? () from /lib/arm-linux-gnueabihf/libc.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 1 (Thread 0xb6fef000 (LWP 3123)):
#0 0xb6f1ba3c in waitpid () from /lib/arm-linux-gnueabihf/libpthread.so.0
#1 0x000b2148 in mono_handle_native_sigsegv (signal=<optimized out>, ctx=<optimized out>) at mini-exceptions.c:2299
#2 <signal handler called>
#3 0xb6de0cdc in raise () from /lib/arm-linux-gnueabihf/libc.so.6
#4 0xb6de4a5c in abort () from /lib/arm-linux-gnueabihf/libc.so.6
#5 0x000136fc in ?? ()
Cannot access memory at address 0x0
#6 0x000136fc in ?? ()
Cannot access memory at address 0x0
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

Anyone knows why this happens or how i can solve it?

Filipe Araujo

moelski
Posts: 63
Joined: Wed Jan 09, 2013 8:16 am

Re: Manual : Install / Compile Mono

Tue Sep 16, 2014 8:30 pm

Hi Filipe,

Well I can´t help you at the moment. For me it works just fine using my guide.
But it would be great if you can write down some more information about your system. Maybe I can doublecheck it here.

* Which system are you using? (Raspberry, CubieTruck, BeagleBone, ...)
* Which OS are you running and what tells "uname -a"?
* Did you have the locales in english while compiling mono?
* What reports "mono --version"?

Dominik

FilipeAraujo
Posts: 3
Joined: Fri Sep 05, 2014 8:39 am

Re: Tutorial : Install / Compile Mono

Mon Oct 27, 2014 3:45 pm

Hi

I've used your guide to install mono from GIT both on Lubuntu and on the RPI, and both times i have the same problem: i can run mono and the .exe file, but monodevelop doesn't start.

I install monodevelop and i can run it, i use your guide to install mono from GIT, it works and runs the .exe file, but monodevelop stops working.

Any idea why this happens?

When i run it in the terminal i get the following:

Unhandled Exception:
System.TypeLoadException: A type load exception has occurred.
at MonoDevelop.Startup.MonoDevelopMain.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: A type load exception has occurred.
at MonoDevelop.Startup.MonoDevelopMain.Main (System.String[] args) [0x00000] in <filename unknown>:0



Thanks for your help

FilipeAraujo

yusuf
Posts: 1
Joined: Sun Apr 10, 2016 2:35 pm

Re: Tutorial : Install / Compile Mono

Sun Apr 10, 2016 2:40 pm

Hi, I know this is an old post, but I wonder if there is a way to backup the compiled and installed files to somewhere else besides rpi. Because I may use multiple rpi's and I dont want to spend 9 hours or so to them every time. if there is a way to backup those files, and then when I buy a new rpi, just placing those files to new rpi, it would be awesome and very time efficient. Thanks...

Dr.Gusman
Posts: 13
Joined: Tue Nov 25, 2014 6:19 pm

Re: Tutorial : Install / Compile Mono

Thu Jul 28, 2016 10:45 am

If the raspberry will be the same model just clone the entire sd card, it will work.

Return to “Other programming languages”