我在 Linux 上的 Mono 下运行了我的 Delphi-prism (.NET) 程序。它运行了一段时间后崩溃并在终端上显示以下错误消息。但同一个程序在 Windows 7 上运行得非常好
谁能告诉我为什么?
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
at System.Windows.Forms.XEventQueue+PaintQueue.Dequeue () [0x00000] in <filename unknown>:0
at System.Windows.Forms.XplatUIX11.GetMessage (System.Object queue_id, System.Windows.Forms.MSG& msg, IntPtr handle, Int32 wFilterMin, Int32 wFilterMax) [0x00000] in <filename unknown>:0
at System.Windows.Forms.XplatUI.GetMessage (System.Object queue_id, System.Windows.Forms.MSG& msg, IntPtr hWnd, Int32 wFilterMin, Int32 wFilterMax) [0x00000] in <filename unknown>:0
at System.Windows.Forms.Application.RunLoop (Boolean Modal, System.Windows.Forms.ApplicationContext context) [0x00000] in <filename unknown>:0
at System.Windows.Forms.Application.Run (System.Windows.Forms.ApplicationContext context) [0x00000] in <filename unknown>:0
at System.Windows.Forms.Application.Run (System.Windows.Forms.Form mainForm) [0x00000] in <filename unknown>:0
at Millennia.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
最佳答案
看起来您的程序正在使用 Windows 窗体。对 Windows 窗体的支持在单声道中并不是最好的。 Mono 提供了运行时和库,但如果您想制作跨平台程序,您还需要考虑您使用的 UI 库。
更新(2016):
我原来的答案可能是错误的。根据this page ,对Windows Forms 2.0的支持已经完成,但是可能还存在不少bug,我没有尝试过。但是,如果您使用第三方 UI 库(例如 Infragistics),它们可能由于 native 调用而无法工作。
看看this page有关移植 Winforms 应用程序的更多信息,包括可以提供帮助的 MoMA 工具。
关于linux - 为什么mono下linux上的.net程序无法运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14693643/