I am currently trying to set up an environment in which I can create winform applications with Visual Studio 2013, and then I want to put on an ARM v7 BeagleBone Black with an attached touch screen, where they should work with Mono.
To do this, I took the Ubuntu 14.10 AMD64 system and created a cross-compilation environment with BeagleBone Black and scratchbox2 binding.
I checked that the toolchain sb2 works correctly by compiling some of its own test programs with it, they work flawlessly on a Ubuntu machine (with sb2), as well as on BeagleBone Black.
Then I compiled mono from the source, once for an Ubuntu machine, and also once for BeagleBone Black. For this, I basically followed this post . As a result, I had a directory with a full mono-tree, whose own components were correctly compiled for ARM. I checked that by running sb2 mono -V on an Ubuntu system, as well as mono -V on BeagleBone Black after copying a monaural directory onto it. I can also run a simple .NET console application that I created using VS2013 on the all-in-one BBB.
Next, I tried to run a simple GUI application, which basically consists of only one form and a button that displays a message. Project parameters in VS were set in the .NET Framework version 4.5 and "Release".
Then I tried to run this EXE with mono on an Ubuntu system, and it worked after setting the parameters. / configure, recompiling mono (--with-tls = __ thread) and installing the necessary libraries (libgdiplus and libx11). But when I try to run the same EXE on BBB, it crashes with this exception:
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 at System.Drawing.Bitmap..ctor (Int32 width, Int32 height, PixelFormat format) [0x00000] in <filename unknown>:0 at System.Drawing.Bitmap..ctor (System.Drawing.Image original, Int32 width, Int32 height) [0x00000] in <filename unknown>:0 at System.Drawing.Bitmap..ctor (System.Drawing.Image original, Size newSize) [0x00000] in <filename unknown>:0 at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:.ctor (System.Drawing.Image,System.Drawing.Size) at System.Windows.Forms.XplatUIX11.DefineCursor (System.Drawing.Bitmap bitmap, System.Drawing.Bitmap mask, Color cursor_pixel, Color mask_pixel, Int32 xHotSpot, Int32 yHotSpot) [0x00000] in <filename unknown>:0 at System.Windows.Forms.XplatUI.DefineCursor (System.Drawing.Bitmap bitmap, System.Drawing.Bitmap mask, Color cursor_pixel, Color mask_pixel, Int32 xHotSpot, Int32 yHotSpot) [0x00000] in <filename unknown>:0 at System.Windows.Forms.Cursor.CreateCursor (System.IO.Stream stream) [0x00000] in <filename unknown>:0 at System.Windows.Forms.Cursor..ctor (System.Type type, System.String resource) [0x00000] in <filename unknown>:0 at System.Windows.Forms.Cursors.get_SizeNWSE () [0x00000] in <filename unknown>:0 at System.Windows.Forms.SizeGrip..ctor (System.Windows.Forms.Control CapturedControl) [0x00000] in <filename unknown>:0 at (wrapper remoting-invoke-with-check) System.Windows.Forms.SizeGrip:.ctor (System.Windows.Forms.Control) at System.Windows.Forms.ScrollableControl.CreateScrollbars () [0x00000] in <filename unknown>:0 at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in <filename unknown>:0 at System.Windows.Forms.ContainerControl..ctor () [0x00000] in <filename unknown>:0 at System.Windows.Forms.Form..ctor () [0x00000] in <filename unknown>:0 at guitest.Form1..ctor () [0x00000] in <filename unknown>:0 at (wrapper remoting-invoke-with-check) guitest.Form1:.ctor () at guitest.Program.Main () [0x00000] in <filename unknown>:0 [ERROR] 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 at System.Drawing.Bitmap..ctor (Int32 width, Int32 height, PixelFormat format) [0x00000] in <filename unknown>:0 at System.Drawing.Bitmap..ctor (System.Drawing.Image original, Int32 width, Int32 height) [0x00000] in <filename unknown>:0 at System.Drawing.Bitmap..ctor (System.Drawing.Image original, Size newSize) [0x00000] in <filename unknown>:0 at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:.ctor (System.Drawing.Image,System.Drawing.Size) at System.Windows.Forms.XplatUIX11.DefineCursor (System.Drawing.Bitmap bitmap, System.Drawing.Bitmap mask, Color cursor_pixel, Color mask_pixel, Int32 xHotSpot, Int32 yHotSpot) [0x00000] in <filename unknown>:0 at System.Windows.Forms.XplatUI.DefineCursor (System.Drawing.Bitmap bitmap, System.Drawing.Bitmap mask, Color cursor_pixel, Color mask_pixel, Int32 xHotSpot, Int32 yHotSpot) [0x00000] in <filename unknown>:0 at System.Windows.Forms.Cursor.CreateCursor (System.IO.Stream stream) [0x00000] in <filename unknown>:0 at System.Windows.Forms.Cursor..ctor (System.Type type, System.String resource) [0x00000] in <filename unknown>:0 at System.Windows.Forms.Cursors.get_SizeNWSE () [0x00000] in <filename unknown>:0 at System.Windows.Forms.SizeGrip..ctor (System.Windows.Forms.Control CapturedControl) [0x00000] in <filename unknown>:0 at (wrapper remoting-invoke-with-check) System.Windows.Forms.SizeGrip:.ctor (System.Windows.Forms.Control) at System.Windows.Forms.ScrollableControl.CreateScrollbars () [0x00000] in <filename unknown>:0 at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in <filename unknown>:0 at System.Windows.Forms.ContainerControl..ctor () [0x00000] in <filename unknown>:0 at System.Windows.Forms.Form..ctor () [0x00000] in <filename unknown>:0 at guitest.Form1..ctor () [0x00000] in <filename unknown>:0 at (wrapper remoting-invoke-with-check) guitest.Form1:.ctor () at guitest.Program.Main () [0x00000] in <filename unknown>:0
I wonder what the problem is? How can I continue here?
BTW: This is the mono version on BBB:
Mono JIT compiler version 3.12.0 (tarball Mo 23. Feb 11:40:46 CET 2015) Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com TLS: __thread SIGSEGV: normal Notifications: epoll Architecture: armel,vfp+fallback Disabled: none Misc: softdebug LLVM: supported, not enabled. GC: sgen
Update: I noticed this little mono utility mono-test-install . When I run it on BBB, it tells me the following:
./mono-test-install Active Mono: Warning: pkg-config could not find mono installed on this system No dotnet pkgconfig found, Windows.Forms, System.Drawing and others will not work
I think this may be my problem. Does anyone know how to succeed in this case? I suppose that for some reason I need to say mono where he can find his libraries and assemblies, but I canβt say for sure ... It would be great if someone could shed some light on this.
Update 2: I was able to get rid of the error shown by mono-test-install manually creating the appropriate environment variables for my mono version ( described here ). In addition, I had to edit the [mono-directory]/usr/local/bin/mcs and fix executable paths. I assume that you can set them automatically with PREFIX=... when setting up mono, but I did not.
Now when I run mono-test-install , I get the following:
Active Mono: /home/root/monotree_armv7/usr/local/bin/mono Other Mono executables: /usr/local/bin/mono Your have a working System.Drawing setup Your file system watcher is: System.IO.InotifyWatcher
So, I think that everything should be in place and correctly configured. But that still doesn't work. When I run my little winforms test program, I get the same exception as above.
After some searching, I found out that there may be a mistake in the monophonic , as I am not the first to come across this. The strange thing, however, is that the same EXE works flawlessly on Ubuntu with the same mono version (just compiled for amd64, not armv7, the same settings). So everything works fine on the PC, it crashes on the hand.
Update: I filed a report with an attached example project that creates problems here .