Ross Harmon
Ross Harmon

Reputation: 15

Mono exceptions after compile on virtual host

I have compiled mono to a local user on a Debian headless virtual host without sudo.

I am getting the following thrown exception on running a program.

mono Program.exe

What is the origin of the exception below, and how do I resolve it?

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

Upvotes: 1

Views: 3229

Answers (2)

Lex Li
Lex Li

Reputation: 63183

Mono's Windows Forms implementation requires X11 to be present on Linux. As this is a headless instance like you described, it just fails to meet the requirements and leads to the exceptions.

Upvotes: 1

SushiHangover
SushiHangover

Reputation: 74144

'System.Windows.Forms.XplatUI' threw an exception. --->
System.ArgumentNullException: Could not open display (X-Server required. Check your DISPLAY environment variable)

Is this VM running a x-server based GUI (x-server/Gnome/Unity/KDE/...)?

  • If yes, are you root? Try as a normal user, no sudo, no su.

  • If no, that just will not work ;-)

Upvotes: 3

Related Questions