在Mono for ARM上运行简单的winforms应用程序

Rob*_*ert 8 c# mono arm cross-compiling beagleboneblack

我目前正在尝试建立一个环境,在这个环境中,我可以使用Visual Studio 2013创建winform应用程序,然后我想将它放在带有附加触摸屏的ARM v7 BeagleBone Black上,它们应该与Mono一起运行.

为了做到这一点,我采用了Ubuntu 14.10 AMD64系统,并使用BeagleBone Black的工具链和scratchbox2创建了一个交叉编译环境.

我通过使用它编译一些原生测试程序来验证工具链sb2是否正常工作,它们在Ubuntu机器(使用sb2)以及BeagleBone Black上运行完美.

接下来,我从源代码编译单声道,一次用于Ubuntu机器,一次用于BeagleBone Black.为此,我主要关注这篇文章.最后,我有一个完整单声道树的目录,其原始组件已经为ARM正确编译.我通过在将单声道目录复制到其上后运行sb2 mono -VUbuntu系统以及mono -VBeagleBone Black来验证.我还可以在BBB的mono上运行我用VS2013创建的简单.NET控制台应用程序.

接下来,我尝试运行一个简单的GUI应用程序,它基本上只包含一个表单和一个弹出消息框的按钮.VS中的项目设置设置为.NET Framework 4.5版和"发布".

接下来,我尝试在Ubuntu系统上使用mono运行这个EXE,它在调整./configure选项,重新编译mono(--with-tls = __ thread)并安装所需的库(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 
Run Code Online (Sandbox Code Playgroud)

我想知道问题可能是什么?我怎么能从这里继续?

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
Run Code Online (Sandbox Code Playgroud)

更新:我刚刚注意到叫这个小单效用mono-test-install.当我在BBB上运行时,它会告诉我:

./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
Run Code Online (Sandbox Code Playgroud)

我想这可能是我的问题.在这种情况下,有人知道如何让事情顺利进行吗?我假设我不得不告诉单声道它可以找到它的库和程序集,但我无法确定...如果有人能够对此有所了解,那就太好了.

更新2:我能够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
Run Code Online (Sandbox Code Playgroud)

所以我认为现在应该有一切就绪并正确设置.但它仍然无效.当我运行我的小winforms测试程序时,我得到了与上面给出的完全相同的异常.

经过一番搜索,我发现单声道可能存在一个错误,因为我不是第一个碰到这个错误的人.然而奇怪的是,相同的EXE在Ubuntu上完美运行,具有相同的单声道版本(仅针对amd64编译而不是armv7,相同的配置选项).所以在PC上一切正常,手臂崩溃.

更新:我提交了一份报告,附带一个示例项目,在此处产生问题.

Ale*_*zub 2

一点挖掘表明,当宽度或高度为非正数时, GDI+ GdipCreateBitmapFromScan0返回。InvalidParameter

向上堆栈跟踪表明,当首选光标大小(由 libX11 报告)与原始光标大小(即 32x32 像素)不同时,Bitmap从 X11 驱动程序调用构造函数。XQueryBestCursor

因此,您的想法是,XQueryBestCursor()BeagleBone 返回光标的宽度/高度为零。通过谷歌搜索,我们找到了描述类似问题的线程。那里甚至还有某种补丁。

我相信您应该使用提供的补丁在 BeagleBone 上重新编译 X11,或者在单声道源中添加一些检查(调用后XQueryBestCursor),以便当 X11 返回零宽度/高度时它使用光标的原始宽度/高度。

UPD:硬件光标大小似乎实际上是由视频驱动程序报告的,因此您可以尝试另一个,例如最近的 xf86-video-fbdev。