Tôi hiện đang cố gắng thiết lập một môi trường mà tôi có thể tạo các ứng dụng winform với Visual Studio 2013 mà sau đó tôi muốn đặt trên ARM v7 BeagleBone Black với màn hình cảm ứng kèm theo phải chạy với Mono.Chạy ứng dụng winforms đơn giản trên Mono cho ARM
Để làm như vậy, tôi đã sử dụng hệ thống Ubuntu 14.10 AMD64 và tạo một môi trường biên dịch chéo với toolchain và scratchbox2 của BeagleBone Black.
Tôi đã xác minh rằng chuỗi công cụ một sb2 hoạt động chính xác bằng cách biên dịch một số chương trình thử nghiệm gốc với nó, chúng chạy hoàn hảo trên máy Ubuntu (với sb2) cũng như trên BeagleBone Black.
Tiếp theo, tôi đã biên soạn mono từ nguồn, một lần cho máy Ubuntu và cũng một lần cho BeagleBone Black. Để làm như vậy, tôi chủ yếu theo dõi this post. Cuối cùng, tôi đã có một thư mục với cây mono hoàn chỉnh có các thành phần gốc đã được biên dịch chính xác cho ARM. Tôi đã xác minh rằng bằng cách chạy sb2 mono -V
trên hệ thống Ubuntu cũng như mono -V
trên BeagleBone Black sau khi sao chép thư mục mono vào đó. Tôi cũng có thể chạy một ứng dụng giao diện điều khiển .NET đơn giản mà tôi đã tạo với VS2013 trên mono của BBB.
Tiếp theo, tôi đã cố gắng chạy một ứng dụng GUI đơn giản về cơ bản chỉ bao gồm một biểu mẫu duy nhất và một nút bật lên một hộp thư. Các thiết lập của dự án trong VS được đặt thành .NET Framework phiên bản 4.5 và "Release".
Tiếp theo, tôi đã thử chạy EXE này với mono trên hệ thống Ubuntu và nó hoạt động sau khi tinh chỉnh các tùy chọn ./configure, biên dịch lại đơn (--with-tls = __ thread) và cài đặt các thư viện cần thiết (libgdiplus và libx11) . Nhưng khi tôi cố gắng chạy cùng một EXE trên BBB, nó bị treo với ngoại lệ này:
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
Tôi tự hỏi vấn đề có thể là gì? Làm thế nào tôi có thể tiếp tục từ đây?
BTW: Đây là phiên bản mono trên 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
Cập nhật: Tôi chỉ nhận thấy tiện ích này mono chút gọi là mono-test-install
. Khi tôi chạy nó trên BBB, nó cho tôi biết điều này:
./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
Tôi nghĩ rằng đó có thể là vấn đề của tôi. Có ai biết làm thế nào để có được những thứ trên đường trong trường hợp này? Tôi cho rằng tôi bằng cách nào đó phải nói với mono rằng nó có thể tìm thấy thư viện và hội đồng của nó ở đâu, nhưng tôi không thể chắc chắn ... Sẽ thật tuyệt nếu ai đó có thể làm sáng tỏ điều này.
Cập nhật 2: tôi đã có thể thoát khỏi những lỗi hiển thị bởi mono-test-install
bằng cách tạo ra các biến môi trường có liên quan để làm bằng tay phiên bản mono của tôi (described here). Ngoài ra, tôi phải chỉnh sửa tệp [mono-directory]/usr/local/bin/mcs
và sửa các đường dẫn đến tệp thi hành. Tôi giả sử bạn có thể đặt chúng tự động với PREFIX=...
khi bạn định cấu hình đơn âm, nhưng tôi không làm điều đó.
Bây giờ, khi tôi chạy mono-test-install
tôi có được điều này:
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
Vì vậy, tôi nghĩ rằng cần phải có tất cả mọi thứ tại chỗ và thiết lập một cách chính xác bây giờ. Nhưng nó vẫn không hoạt động.Khi tôi chạy chương trình thử nghiệm winforms nhỏ của tôi, tôi nhận được ngoại lệ rất giống như đã nêu ở trên.
Sau một số tìm kiếm, tôi phát hiện ra rằng có thể là bug in mono vì tôi không phải là người đầu tiên chạy chương trình này. Điều kỳ lạ tuy nhiên là một thực tế rằng cùng một EXE chạy hoàn hảo trên Ubuntu với phiên bản mono rất giống nhau (chỉ biên soạn cho amd64 và không armv7, cùng một tùy chọn cấu hình). Vì vậy, trên PC mọi thứ hoạt động tốt, trên cánh tay nó bị treo.
Cập nhật: Tôi đã gửi báo cáo với dự án mẫu đính kèm để tạo ra sự cố here.
lẽ là một gợi ý câm, nhưng những gì xảy ra nếu bạn thấp hơn phiên bản .NET Framework 3.5 để? – Odrai
Tôi đã thử điều đó, nó cũng không hoạt động. – Robert
Hãy thử [MONO_LOG_LEVEL = debug] (http://www.mono-project.com/docs/debug+profile/debug/) để bạn có thêm thông tin (lỗi). – Odrai