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

编程入门 行业动态 更新时间:2024-10-11 01:16:26
本文介绍了在Mono for ARM上运行简单的winforms应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

我通过编译一些本机测试程序来验证sb2的工具链是否可以正常工作,它们确实可以在Ubuntu计算机(带有sb2)以及BeagleBone Black上完美运行.

接下来,我从源代码编译了mono,一次是针对Ubuntu机器,另一次是针对BeagleBone Black.为此,我主要关注这篇文章.最后,我有一个目录,其中包含完整的Mono树,其本机组件已为ARM正确编译.我复制了Mono目录后,通过在Ubuntu系统上以及BeagleBone Black上运行sb2 mono -V以及在BeagleBone Black上运行mono -V进行了验证.我还可以在BBB的单声道上运行用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 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

我认为这可能是我的问题.在这种情况下,有人知道如何使事情步入正轨吗?我以为我必须以某种方式告诉mono在哪里可以找到它的库和程序集,但是我不能确定...如果有人可以对此有所了解,那将是很好的.

更新2: 通过为我的手工单声道版本(在此描述).另外,我还必须编辑文件[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在单声道中为我不是第一个遇到这个问题的人.然而,奇怪的是,同一EXE在具有完全相同的Mono版本(仅针对amd64而不是armv7编译,具有相同的配置选项)上的Ubuntu上完美运行.因此,在PC上,一切正常,手臂崩溃.

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

解决方案

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

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

因此,您的BeagleBone上的XQueryBestCursor()返回的光标宽度/高度为零.进行一些谷歌搜索使我们进入线程描述一个类似的问题.那里甚至有某种补丁.

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

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

I am currently trying to set up an environment in which I can create winform applications with Visual Studio 2013 that I then want to put on an ARM v7 BeagleBone Black with an attached touchscreen where they are supposed to run with Mono.

In order to do so, I took a Ubuntu 14.10 AMD64 system and created a cross-compile environment with the BeagleBone Black's toolchain and scratchbox2.

I verified that the toolchain an sb2 work correctly by compiling some native test programs with it, they do run flawlessly on the Ubuntu machine (with sb2) as well as on the BeagleBone Black.

Next, I compiled mono from source, once for the Ubuntu machine and also once for the BeagleBone Black. To do so, I mainly followed this post. In the end I had a directory with the complete mono tree whose native components had been correctly compiled for ARM. I verified that by running sb2 mono -V on the Ubuntu system as well as mono -V on the BeagleBone Black after copying the mono directory onto it. I can also run a simple .NET console application that I created with VS2013 on the BBB's mono.

Next I tried to run a simple GUI application that basically only consists of a single form and a button that pops up a messagebox. The project settings in VS were set to .NET Framework version 4.5 and "Release".

Next, I tried to run this EXE with mono on the Ubuntu system and it worked after tweaking the ./configure options, recompiling mono (--with-tls=__thread) and installing the required libraries (libgdiplus and libx11). But when I try to run the same EXE on the 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 might be? How can I go on from here?

BTW: This is the mono version on the 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 TLS: __thread SIGSEGV: normal Notifications: epoll Architecture: armel,vfp+fallback Disabled: none Misc: softdebug LLVM: supported, not enabled. GC: sgen

Update: I just noticed this little mono utility called mono-test-install. When I run it on the BBB, it tells me this:

./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 that may be my problem. Does somebody know how to get things on track in this case? I assume that I somehow have to tell mono where it can find its libraries and assemblies, but I can't tell 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 by creating the relevant environment variables for my hand-made mono version (described here). Also, I had to edit the file [mono-directory]/usr/local/bin/mcs and correct the paths to the executables. I assume you can set them automatically with PREFIX=... when you configure mono, but I didn't do that.

Now, when I run mono-test-install I get this:

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 there should be everything in place and set up correctly now. But it still does not work. When I run my little winforms test program, I get the very same exception as given above.

After some searching I found out that there is probably a bug in mono as I am not the first one to run into this. The strange thing however is the fact that the same EXE runs flawlessly on Ubuntu with the very same mono version (just compiled for amd64 and not armv7, same configure options). So on the PC everything works fine, on arm it crashes.

Update: I filed a report with an attached sample project that produces the problems here.

解决方案

A bit of digging shows that GDI+ GdipCreateBitmapFromScan0 returns InvalidParameter when width or height is a non-positive number.

Going upper the stack trace indicates that Bitmap constructor is called from X11 driver when preferred cursor size (reported by XQueryBestCursor from libX11) differs from original cursor size (which is 32x32 pixels).

So the thought is that XQueryBestCursor() on your BeagleBone returns zero width/height for cursor. A bit of googling gets us to the thread describing a similar issue. There's even some kind of patch there.

I believe you should either recompile X11 on your BeagleBone with a patch provided, or add some checks in mono source (after calling XQueryBestCursor) so it use cursor's original width/height when X11 returns zero width/height.

UPD: HW cursor size seems to be actually reported by video driver, so you can probably just try another one, like recent xf86-video-fbdev.

更多推荐

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

本文发布于:2023-11-25 05:59:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1628600.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   简单   Mono   ARM   winforms

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!