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環境変数を確認してください)パラメータ名:ディスプレイ

次の2つのうちの1つを実行したいようです。

  1. Xデスクトップにアクセスせずにシェルでモノラルアプリケーションを起動する
  2. ディスプレイにアクセスできないユーザーとして実行

この手がかりはレッドガストフォーラム同じ問題があるようです。

潜在的なソリューション

あなたが必要とする:

  1. Xデスクトップを所有しているのと同じユーザーとしてvpsにsshを接続し、$ DISPLAY環境変数を「:0.0」に設定します。
  2. xhost +他のユーザーとしてmonoコマンドを実行する前に、デスクトップを所有しているユーザーとして実行してください。 (他のユーザーにも$ DISPLAY変数を設定することを忘れないでください!)

次のようにモノラルコマンドを実行することもできると思います。

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

メモ:$YOURUSERはXデスクトップを所有しているユーザーです。

おすすめ記事