CentOS 5 CLI에서 Mono 실행

CentOS 5 CLI에서 Mono 실행

Linux CentOS 5 32비트에서 실행되는 vps 서버(가상 개인 서버)가 있고 vncserverX-Windows, GNOME 및 KDE 환경을 설치했으며 Windows 7 데스크탑의 vncviewer에서 VNC 서버에 연결합니다.

이제 명령을 실행합니다

mono Radegast.exe

터미널에서 나는 얻었다

[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 -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 

답변1

귀하의 질문에 이것을 명시 적으로 언급하지는 않았지만 발생한 오류는 다음과 같습니다.

[오류]: - 처리되지 않은 System.TypeInitializationException: System.Windows.Forms.XplatUI에 대한 유형 이니셜라이저에서 예외가 발생했습니다. ---> System.ArgumentNullException: 디스플레이를 열 수 없습니다(X-Server가 필요합니다. DISPLAY 환경 변수를 확인하세요). 매개변수 이름: 디스플레이

다음 두 가지 중 하나를 수행하려는 것 같습니다.

  1. X 데스크탑에 액세스할 수 없는 셸에서 모노 앱을 실행합니다.
  2. 디스플레이에 액세스할 수 있는 권한이 없는 사용자로 실행되고 있습니다.

이 스레드는Radegast 포럼같은 문제인 것 같습니다.

잠재적인 솔루션

다음 중 하나를 수행해야 합니다.

  1. X Desktop을 소유한 동일한 사용자로 vps에 ssh'ing한 후 $DISPLAY 환경 변수를 ":0.0"으로 설정합니다.
  2. xhost +다른 사용자로 mono 명령을 실행하기 전에 데스크탑을 소유한 사용자로 실행하십시오 (이 다른 사용자에 대해서도 $DISPLAY 변수를 설정하는 것을 잊지 마십시오!)

다음과 같이 모노 명령을 실행할 수도 있다고 생각합니다.

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

메모:$YOURUSER는 X 데스크탑을 소유한 사용자입니다.

답변2

C# 코드에 GUI가 있는 경우 해당 코드에 $DISPLAY를 할당해야 합니다. echo $DISPLAY원격 Linux에서 $DISPLAY를 먼저 제공할 수 있습니다 .

  1. 당신이RDP(원격 데스크톱 프로토콜) 패키지를 설치할 수 있습니다.xrdp.

    $ sudo apt-get install xrdp
    
  2. 원격 서버(Remmina, )에 접속합니다.

  3. 터미널을 열고 $DISPLAY를 얻으세요.

    $echo $DISPLAY
    :10.0
    
  4. SSH를 사용하여 모노 프로그램을 실행합니다.

    $ ssh [email protected]
    $ export DISPLAY=:10.0
    $ mono server.exe > /dev/null 2> /dev/null &
    

관련 정보