尝试了几个小时都无法让它正常工作后,我决定是时候发帖求助了。
我有一个相当基础的 C# Windows Forms 应用程序,在Windows上可以编译和运行得很好。整个项目的设计是为了在树莓派上运行,所以我将项目移到了树莓派上并进行了编译。花费了几个小时终于使其编译成功(发现我需要引用 MySql.Data.dll 文件),最终它编译通过且无错误!
但是当我运行时:
Mono Administration.exe
我遇到了一个很大的错误,但是在网上找到的信息非常少:
pi@raspberrypi /media/WAYNEIO/pi/ProjectNibiru/ProjectNibiru $ mono Administration.exe
Stacktrace:
at System.Drawing.Font.CreateFont (string,single,System.Drawing.FontStyle,System.Drawing.GraphicsUnit,byte,bool) <0x00143>
at System.Drawing.Font..ctor (string,single,System.Drawing.FontStyle,System.Drawing.GraphicsUnit,byte,bool) <0x0007f>
at System.Drawing.Font..ctor (string,single,string) <0x00057>
at (wrapper remoting-invoke-with-check) System.Drawing.Font..ctor (string,single,string) <0xffffffff>
at System.Drawing.SystemFonts.get_DefaultFont () <0x00073>
at System.Windows.Forms.Theme..ctor () <0x0002f>
at System.Windows.Forms.ThemeWin32Classic..ctor () <0x00013>
at System.Windows.Forms.ThemeVisualStyles..ctor () <0x00013>
at System.Windows.Forms.ThemeEngine..cctor () <0x0007f>
at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) <0xffffffff>
at System.Windows.Forms.X11DesktopColors..cctor () <0x000bb>
at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) <0xffffffff>
at System.Windows.Forms.XplatUIX11..ctor () <0x001af>
at System.Windows.Forms.XplatUIX11.GetInstance () <0x00073>
at System.Windows.Forms.XplatUI..cctor () <0x00157>
at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) <0xffffffff>
at System.Windows.Forms.Application.EnableVisualStyles () <0x00023>
at ProjectNibiru.Program.Main () <0x0000b>
at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) <0xffffffff>
Native stacktrace:
Debug info from gdb:
Cannot access memory at address 0x0
Cannot access memory at address 0x0
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
[New Thread 0x4093b460 (LWP 2224)]
0x40085f30 in read () from /lib/arm-linux-gnueabihf/libpthread.so.0
Id Target Id Frame
2 Thread 0x4093b460 (LWP 2224) "mono" 0x40084d84 in sem_wait@@GLIBC_2.4 () from /lib/arm-linux-gnueabihf/libpthread.so.0
* 1 Thread 0x400cd000 (LWP 2223) "mono" 0x40085f30 in read () from /lib/arm-linux-gnueabihf/libpthread.so.0
Thread 2 (Thread 0x4093b460 (LWP 2224)):
#0 0x40084d84 in sem_wait@@GLIBC_2.4 () from /lib/arm-linux-gnueabihf/libpthread.so.0
#1 0x00195a40 in mono_sem_wait ()
#2 0x000ea384 in ?? ()
#3 0x000ea384 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
Thread 1 (Thread 0x400cd000 (LWP 2223)):
#0 0x40085f30 in read () from /lib/arm-linux-gnueabihf/libpthread.so.0
#1 0x40085770 in __pthread_enable_asynccancel () from /lib/arm-linux-gnueabihf/libpthread.so.0
#2 0x00000000 in ?? ()
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
Aborted
有人能提供建议,说明为什么会出现这个问题,并请告知如何解决吗?
需要注意的事项是:无论我使用“Xbuild”还是“dmcs”进行编译,或者是在Windows上编译并复制到树莓派上,都会出现此问题。编译基本的Hello World脚本没有问题,因此可能与Windows.Forms或MySql.Data有关。另外,树莓派正在运行Debian。
mono --trace
来更好地了解正在发生的事情。要获取最详细的信息,您需要一个带有 mono 支持和带有调试信息的 mono 库的gdb
。 - Jester