我目前正在尝试设置一个环境,在该环境中,我可以使用Visual Studio 2013创建winform应用程序,然后将其添加到带有附加触摸屏的ARM v7 BeagleBone Black应该与Mono一起运行。在Mono上为ARM运行简单的winforms应用程序
为了做到这一点,我使用了Ubuntu 14.10 AMD64系统,并使用BeagleBone Black的工具链和scratchbox2创建了一个交叉编译环境。
我通过编译一些本地测试程序正确验证了sb2工具链的正常工作,它们在Ubuntu机器上(使用sb2)以及在BeagleBone Black上运行得非常完美。
接下来,我从源代码编译单声道,一次为Ubuntu机器,一次为BeagleBone Black。为此,我主要遵循this post。最后,我有一个完整的单声道树的目录,其本机组件已经正确编译为ARM。我通过在Ubuntu系统上运行sb2 mono -V
以及在BeagleBone Black上运行mono -V
,然后将单声道目录复制到它上面。我还可以运行一个简单的.NET控制台应用程序,该应用程序是使用VS2013在BBB的mono上创建的。
接下来我尝试运行一个简单的GUI应用程序,它基本上只包含一个窗体和一个弹出消息框的按钮。 VS中的项目设置被设置为.NET Framework版本4.5和“Release”。我试着在Ubuntu系统上运行这个单声道的EXE,它调整了./configure选项后,重新编译单声道(--with-tls = __线程)并安装了所需的库(libgdiplus和libx11) 。但是,当我尝试运行在BBB同一EXE崩溃与此异常:
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
我不知道这个问题可能是什么?我怎么能从这里继续?
BTW:这是在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
更新:我只是注意到叫mono-test-install
这个小单效用。当我在BBB运行它,它告诉我:
我认为这可能是我的问题。在这种情况下,有人知道如何让事情顺利进行吗?我认为我必须告诉mono在哪里可以找到它的库和程序集,但我无法确定......如果有人能够对此有所了解,那将会很棒。
更新2:我能够通过创建我的手工制作的单版(described here)相关的环境变量摆脱由mono-test-install
所示的错误。另外,我必须编辑文件[mono-directory]/usr/local/bin/mcs
并更正可执行文件的路径。我假设你可以在配置单声道时用PREFIX=...
自动设置它们,但我没有这样做。
现在,当我运行mono-test-install
我得到这个:
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
所以我觉得应该是一步到位,现在设置正确。但它仍然不起作用。当我运行我的小winforms测试程序时,我得到了与上面给出的非常相同的异常。
经过一番搜索,我发现有可能是bug in mono,因为我不是第一个遇到这个问题。然而奇怪的事实是,相同的EXE在Ubuntu上运行完全相同的单声道版本(仅编译为amd64而不是armv7,相同的配置选项)。所以在个人电脑上一切正常,胳膊崩溃。
更新:我提交了一份附带示例项目的报告,该项目产生了问题here。
也许一个愚蠢的建议,但如果您将.NET Framework版本降低到3.5,会发生什么? – Odrai 2015-03-01 09:05:26
我试过了,它也没有工作。 – Robert 2015-03-01 15:42:47
尝试[MONO_LOG_LEVEL = debug](http://www.mono-project.com/docs/debug+profile/debug/),以获得更多(错误)信息。 – Odrai 2015-03-01 18:21:16