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

问题描述 投票:8回答:1

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

为了做到这一点,我采用了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来验证。我还可以在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 

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

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-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

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

更新2:通过为我手工制作的单声道版本(mono-test-install)创建相关的环境变量,我能够摆脱described here显示的错误。此外,我不得不编辑文件[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,相同的配置选项)。所以在PC上一切正常,手臂崩溃。

更新:我提交了一份报告,其附带的示例项目产生了问题here

c# mono arm cross-compiling beagleboneblack
1个回答
2
投票

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

upper the stack trace表示当首选游标大小(由libz11的Bitmap报告)与原始游标大小(32x32像素)不同时,从X11驱动程序调用XQueryBestCursor构造函数。

所以我们的想法是你的BeagleBone上的XQueryBestCursor()为光标返回零宽度/高度。一些谷歌搜索让我们到thread描述类似的问题。那里甚至还有某种补丁。

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

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

© www.soinside.com 2019 - 2024. All rights reserved.