Running Mono on CentOS 5 CLI

5,233

You don't explicitly state this in your question but the error you're encountering:

[ERROR]: - Unhandled System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.XplatUI ---> System.ArgumentNullException: Could not open display (X-Server required. Check you DISPLAY environment variable) Parameter name: Display

Sounds like you're attempting to do one of 2 things:

  1. launch the mono app in a shell that has no access to the X Desktop
  2. is being run as a user that doesn't have permissions to access the display

This thread on the Radegast forum sounds like your same issue.

Potential solutions

You'll need to either:

  1. set the $DISPLAY environment variable to ":0.0" after ssh'ing into the vps as the same user that owns the X Desktop
  2. run xhost + as the user that owns the desktop prior to running your mono command as some other user (don't forget to set the $DISPLAY variable for this other user too!)

I believe you could also run your mono command like this:

% XAUTHORITY=/home/$YOURUSER/.Xauthority DISPLAY=:0.0 mono Radegast.exe

NOTE: $YOURUSER is the user that owns the X Desktop.

Share:
5,233

Related videos on Youtube

iLinux85
Author by

iLinux85

Updated on September 18, 2022

Comments

  • iLinux85
    iLinux85 over 1 year

    I have vps server (virtual private server) running on Linux CentOS 5 32 bit , I installed vncserver X-Windows , GNOME and KDE environment and I connect to the VNC server from vncviewer in my Windows 7 Desktop

    now I execute the command

    mono Radegast.exe
    

    in terminal and I got

    [ERROR]: - Unhandled System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.XplatUI ---> System.ArgumentNullException: Could not open display (X-Server required. Check you DISPLAY environment variable)
        Parameter name: Display
          at System.Windows.Forms.XplatUIX11.SetDisplay (IntPtr display_handle) [0x00000]
          at System.Windows.Forms.XplatUIX11..ctor () [0x00000]
          at System.Windows.Forms.XplatUIX11.GetInstance () [0x00000]
          at System.Windows.Forms.XplatUI..cctor () [0x00000]
          --- End of inner exception stack trace ---
          at System.Windows.Forms.Application.EnableVisualStyles () [0x00000]
          at Radegast.MainProgram.RunRadegast (System.String[] args) [0x00000]
          at Radegast.MainProgram.Main (System.String[] args) [0x00000] : An exception was thrown by the type initializer for System.Windows.Forms.XplatUI
          at System.Windows.Forms.Application.EnableVisualStyles () [0x00000]
          at Radegast.MainProgram.RunRadegast (System.String[] args) [0x00000]
          at Radegast.MainProgram.Main (System.String[] args) [0x00000]
    

    mono version is

    # mono -V
    Mono JIT compiler version 2.4.2.3 (tarball Sat Apr 20 19:49:33 MSD 2013)
    Copyright (C) 2002-2008 Novell, Inc and Contributors. www.mono-project.com
            TLS:           __thread
            GC:            Included Boehm (with typed GC)
            SIGSEGV:       altstack
            Notifications: epoll
            Architecture:  x86
            Disabled:      none 
    
    • tink
      tink about 11 years
      Are you running this from within the vnc desktop session as the very same user owning the session? Or do you su to someone else to run it? If you do the latter, or are ssh-ing in in parallel to vnc there's your problem.
    • slm
      slm about 11 years
      Reading his question it sounds like he's running it from within the vnc session, but I agree it's something with the display.