我已经在没有sudo的Debian无头虚拟主机上为本地用户编译了mono。
我在运行程序时遇到以下抛出的异常。
mono Program.exe
以下例外的起源是什么,我该如何解决?
Unhandled Exception:
System.TypeInitializationException: The type initializer for 'System.Windows.Forms.WindowsFormsSynchronizationContext' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Windows.Forms.XplatUI' threw an exception. ---> System.ArgumentNullException: Could not open display (X-Server required. Check your DISPLAY environment variable)
Parameter name: Display
at System.Windows.Forms.XplatUIX11.SetDisplay (IntPtr display_handle) <0x40865c60 + 0x00b8f> in <filename unknown>:0
at System.Windows.Forms.XplatUIX11..ctor () <0x40863f70 + 0x001df> in <filename unknown>:0
at System.Windows.Forms.XplatUIX11.GetInstance () <0x40863da0 + 0x0005b> in <filename unknown>:0
at System.Windows.Forms.XplatUI..cctor () <0x40863a70 + 0x0013b> in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.Theme.get_MenuAccessKeysUnderlined () <0x40863a20 + 0x0000f> in <filename unknown>:0
at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () <0x4085f3f0 + 0x00017> in <filename unknown>:0
at System.Windows.Forms.Control..ctor () <0x4085e0f0 + 0x0023b> in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () <0x4085f320 + 0x00023> in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.Control..ctor () <0x4085e0f0 + 0x00053> in <filename unknown>:0
at System.Windows.Forms.ScrollableControl..ctor () <0x4085dbb0 + 0x00013> in <filename unknown>:0
at System.Windows.Forms.ContainerControl..ctor () <0x4085da20 + 0x0002b> in <filename unknown>:0
at System.Windows.Forms.Form..ctor () <0x4085d210 + 0x000b7> in <filename unknown>:0
at System.Windows.Forms.MessageBox+MessageBoxForm..ctor (IWin32Window owner, System.String text, System.String caption, MessageBoxButtons buttons, MessageBoxIcon icon, Boolean displayHelpButton) <0x4085acb0 + 0x0008f> in <filename unknown>:0
at System.Windows.Forms.MessageBox+MessageBoxForm..ctor (IWin32Window owner, System.String text, System.String caption, MessageBoxButtons buttons, MessageBoxIcon icon) <0x4085ac50 + 0x00047> in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.MessageBox+MessageBoxForm:.ctor (System.Windows.Forms.IWin32Window,string,string,System.Windows.Forms.MessageBoxButtons,System.Windows.Forms.MessageBoxIcon)
at System.Windows.Forms.MessageBox.Show (System.String text) <0x4085ab30 + 0x00043> in <filename unknown>:0
at Jackett.Program.Main (System.String[] args) <0x40859a10 + 0x00107> in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'System.Windows.Forms.WindowsFormsSynchronizationContext' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Windows.Forms.XplatUI' threw an exception. ---> System.ArgumentNullException: Could not open display (X-Server required. Check your DISPLAY environment variable)
Parameter name: Display
at System.Windows.Forms.XplatUIX11.SetDisplay (IntPtr display_handle) <0x40865c60 + 0x00b8f> in <filename unknown>:0
at System.Windows.Forms.XplatUIX11..ctor () <0x40863f70 + 0x001df> in <filename unknown>:0
at System.Windows.Forms.XplatUIX11.GetInstance () <0x40863da0 + 0x0005b> in <filename unknown>:0
at System.Windows.Forms.XplatUI..cctor () <0x40863a70 + 0x0013b> in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.Theme.get_MenuAccessKeysUnderlined () <0x40863a20 + 0x0000f> in <filename unknown>:0
at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () <0x4085f3f0 + 0x00017> in <filename unknown>:0
at System.Windows.Forms.Control..ctor () <0x4085e0f0 + 0x0023b> in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () <0x4085f320 + 0x00023> in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.Control..ctor () <0x4085e0f0 + 0x00053> in <filename unknown>:0
at System.Windows.Forms.ScrollableControl..ctor () <0x4085dbb0 + 0x00013> in <filename unknown>:0
at System.Windows.Forms.ContainerControl..ctor () <0x4085da20 + 0x0002b> in <filename unknown>:0
at System.Windows.Forms.Form..ctor () <0x4085d210 + 0x000b7> in <filename unknown>:0
at System.Windows.Forms.MessageBox+MessageBoxForm..ctor (IWin32Window owner, System.String text, System.String caption, MessageBoxButtons buttons, MessageBoxIcon icon, Boolean displayHelpButton) <0x4085acb0 + 0x0008f> in <filename unknown>:0
at System.Windows.Forms.MessageBox+MessageBoxForm..ctor (IWin32Window owner, System.String text, System.String caption, MessageBoxButtons buttons, MessageBoxIcon icon) <0x4085ac50 + 0x00047> in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.MessageBox+MessageBoxForm:.ctor (System.Windows.Forms.IWin32Window,string,string,System.Windows.Forms.MessageBoxButtons,System.Windows.Forms.MessageBoxIcon)
at System.Windows.Forms.MessageBox.Show (System.String text) <0x4085ab30 + 0x00043> in <filename unknown>:0
at Jackett.Program.Main (System.String[] args) <0x40859a10 + 0x00107> in <filename unknown>:0
nakedmancow@chronos:~/install/Release$ ls
CsQuery.dll Jackett.pdb Newtonsoft.Json.xml
CsQuery.xml Jackett.vshost.exe NLog.dll
CurlSharp.dll Jackett.vshost.exe.config NLog.xml
CurlSharp.pdb Jackett.vshost.exe.manifest WebContent
Jackett.exe ModernHttpClient.dll
Jackett.exe.config Newtonsoft.Json.dll
nakedmancow@chronos:~/install/Release$ mono Jackett.exe
Unhandled Exception:
System.TypeInitializationException: The type initializer for 'System.Windows.Forms.WindowsFormsSynchronizationContext' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Windows.Forms.XplatUI' threw an exception. ---> System.ArgumentNullException: Could not open display (X-Server required. Check your DISPLAY environment variable)
Parameter name: Display
at System.Windows.Forms.XplatUIX11.SetDisplay (IntPtr display_handle) <0x40bd0c60 + 0x00b8f> in <filename unknown>:0
at System.Windows.Forms.XplatUIX11..ctor () <0x40bcef70 + 0x001df> in <filename unknown>:0
at System.Windows.Forms.XplatUIX11.GetInstance () <0x40bceda0 + 0x0005b> in <filename unknown>:0
at System.Windows.Forms.XplatUI..cctor () <0x40bcea70 + 0x0013b> in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.Theme.get_MenuAccessKeysUnderlined () <0x40bcea20 + 0x0000f> in <filename unknown>:0
at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () <0x40bca3f0 + 0x00017> in <filename unknown>:0
at System.Windows.Forms.Control..ctor () <0x40bc90f0 + 0x0023b> in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () <0x40bca320 + 0x00023> in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.Control..ctor () <0x40bc90f0 + 0x00053> in <filename unknown>:0
at System.Windows.Forms.ScrollableControl..ctor () <0x40bc8bb0 + 0x00013> in <filename unknown>:0
at System.Windows.Forms.ContainerControl..ctor () <0x40bc8a20 + 0x0002b> in <filename unknown>:0
at System.Windows.Forms.Form..ctor () <0x40bc8210 + 0x000b7> in <filename unknown>:0
at System.Windows.Forms.MessageBox+MessageBoxForm..ctor (IWin32Window owner, System.String text, System.String caption, MessageBoxButtons buttons, MessageBoxIcon icon, Boolean displayHelpButton) <0x40bc5cb0 + 0x0008f> in <filename unknown>:0
at System.Windows.Forms.MessageBox+MessageBoxForm..ctor (IWin32Window owner, System.String text, System.String caption, MessageBoxButtons buttons, MessageBoxIcon icon) <0x40bc5c50 + 0x00047> in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.MessageBox+MessageBoxForm:.ctor (System.Windows.Forms.IWin32Window,string,string,System.Windows.Forms.MessageBoxButtons,System.Windows.Forms.MessageBoxIcon)
at System.Windows.Forms.MessageBox.Show (System.String text) <0x40bc5b30 + 0x00043> in <filename unknown>:0
at Jackett.Program.Main (System.String[] args) <0x40bc4a10 + 0x00107> in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'System.Windows.Forms.WindowsFormsSynchronizationContext' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Windows.Forms.XplatUI' threw an exception. ---> System.ArgumentNullException: Could not open display (X-Server required. Check your DISPLAY environment variable)
Parameter name: Display
at System.Windows.Forms.XplatUIX11.SetDisplay (IntPtr display_handle) <0x40bd0c60 + 0x00b8f> in <filename unknown>:0
at System.Windows.Forms.XplatUIX11..ctor () <0x40bcef70 + 0x001df> in <filename unknown>:0
at System.Windows.Forms.XplatUIX11.GetInstance () <0x40bceda0 + 0x0005b> in <filename unknown>:0
at System.Windows.Forms.XplatUI..cctor () <0x40bcea70 + 0x0013b> in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.Theme.get_MenuAccessKeysUnderlined () <0x40bcea20 + 0x0000f> in <filename unknown>:0
at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () <0x40bca3f0 + 0x00017> in <filename unknown>:0
at System.Windows.Forms.Control..ctor () <0x40bc90f0 + 0x0023b> in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () <0x40bca320 + 0x00023> in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.Control..ctor () <0x40bc90f0 + 0x00053> in <filename unknown>:0
at System.Windows.Forms.ScrollableControl..ctor () <0x40bc8bb0 + 0x00013> in <filename unknown>:0
at System.Windows.Forms.ContainerControl..ctor () <0x40bc8a20 + 0x0002b> in <filename unknown>:0
at System.Windows.Forms.Form..ctor () <0x40bc8210 + 0x000b7> in <filename unknown>:0
at System.Windows.Forms.MessageBox+MessageBoxForm..ctor (IWin32Window owner, System.String text, System.String caption, MessageBoxButtons buttons, MessageBoxIcon icon, Boolean displayHelpButton) <0x40bc5cb0 + 0x0008f> in <filename unknown>:0
at System.Windows.Forms.MessageBox+MessageBoxForm..ctor (IWin32Window owner, System.String text, System.String caption, MessageBoxButtons buttons, MessageBoxIcon icon) <0x40bc5c50 + 0x00047> in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.MessageBox+MessageBoxForm:.ctor (System.Windows.Forms.IWin32Window,string,string,System.Windows.Forms.MessageBoxButtons,System.Windows.Forms.MessageBoxIcon)
at System.Windows.Forms.MessageBox.Show (System.String text) <0x40bc5b30 + 0x00043> in <filename unknown>:0
at Jackett.Program.Main (System.String[] args) <0x40bc4a10 + 0x00107> in <filename unknown>:0
答案 0 :(得分:2)
'System.Windows.Forms.XplatUI' threw an exception. --->
System.ArgumentNullException: Could not open display (X-Server required. Check your DISPLAY environment variable)
此VM是否运行基于x服务器的GUI(x-server / Gnome / Unity / KDE / ...)?
如果是的话,你是根吗?尝试普通用户,没有sudo,没有su。
如果不是,那就行不通; - )
答案 1 :(得分:1)
Mono的Windows Forms实现要求X11出现在Linux上。由于这是一个像你所描述的无头实例,它只是无法满足要求并导致例外。