我目前正在嘗試設置一個環境,在該環境中,我可以使用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