无法从 SSH 启动 MonoGame,但可以从 GUI 启动

Cannot start MonoGame from SSH, but can from GUI

所以我想从我的 SSH 终端开始游戏。

它真的很奇怪,当我直接从我的 linux GUI 执行它时,它有效。但是当我使用 SSH 客户端远程连接时,它就崩溃了。好像和我的显卡驱动有关系

Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for OpenTK.DisplayDevice ---> System.IO.DirectoryNotFoundException: Directory '/dev/dri' not found.
  at System.IO.Directory.ValidateDirectoryListing (System.String path, System.String searchPattern, System.Boolean& stop) [0x00000] in <filename unknown>:0 
  at System.IO.Directory.GetFileSystemEntries (System.String path, System.String searchPattern, FileAttributes mask, FileAttributes attrs) [0x00000] in <filename unknown>:0 
  at System.IO.Directory.GetFiles (System.String path, System.String searchPattern) [0x00000] in <filename unknown>:0 
  at System.IO.Directory.GetFiles (System.String path) [0x00000] in <filename unknown>:0 
  at OpenTK.Platform.Linux.LinuxFactory.CreateDisplay (System.IntPtr& gbm_device, System.IntPtr& egl_display) [0x00000] in <filename unknown>:0 
  at OpenTK.Platform.Linux.LinuxFactory.get_gpu_fd () [0x00000] in <filename unknown>:0 
  at OpenTK.Platform.Linux.LinuxFactory.CreateDisplayDeviceDriver () [0x00000] in <filename unknown>:0 
  at OpenTK.DisplayDevice..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at OpenTK.NativeWindow..ctor () [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.OpenTKGameWindow.Initialize (Microsoft.Xna.Framework.Game game) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.OpenTKGameWindow..ctor (Microsoft.Xna.Framework.Game game) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.OpenTKGamePlatform..ctor (Microsoft.Xna.Framework.Game game) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.GamePlatform.Create (Microsoft.Xna.Framework.Game game) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.Game..ctor () [0x00000] in <filename unknown>:0 
  at TestGame.Game1..ctor () [0x00000] in <filename unknown>:0 
  at TestGame.Program.RunGame () [0x00000] in <filename unknown>:0 
  at TestGame.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for OpenTK.DisplayDevice ---> System.IO.DirectoryNotFoundException: Directory '/dev/dri' not found.
  at System.IO.Directory.ValidateDirectoryListing (System.String path, System.String searchPattern, System.Boolean& stop) [0x00000] in <filename unknown>:0 
  at System.IO.Directory.GetFileSystemEntries (System.String path, System.String searchPattern, FileAttributes mask, FileAttributes attrs) [0x00000] in <filename unknown>:0 
  at System.IO.Directory.GetFiles (System.String path, System.String searchPattern) [0x00000] in <filename unknown>:0 
  at System.IO.Directory.GetFiles (System.String path) [0x00000] in <filename unknown>:0 
  at OpenTK.Platform.Linux.LinuxFactory.CreateDisplay (System.IntPtr& gbm_device, System.IntPtr& egl_display) [0x00000] in <filename unknown>:0 
  at OpenTK.Platform.Linux.LinuxFactory.get_gpu_fd () [0x00000] in <filename unknown>:0 
  at OpenTK.Platform.Linux.LinuxFactory.CreateDisplayDeviceDriver () [0x00000] in <filename unknown>:0 
  at OpenTK.DisplayDevice..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at OpenTK.NativeWindow..ctor () [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.OpenTKGameWindow.Initialize (Microsoft.Xna.Framework.Game game) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.OpenTKGameWindow..ctor (Microsoft.Xna.Framework.Game game) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.OpenTKGamePlatform..ctor (Microsoft.Xna.Framework.Game game) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.GamePlatform.Create (Microsoft.Xna.Framework.Game game) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.Game..ctor () [0x00000] in <filename unknown>:0 
  at TestGame.Game1..ctor () [0x00000] in <filename unknown>:0 
  at TestGame.Program.RunGame () [0x00000] in <filename unknown>:0 
  at TestGame.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 

我虽然创建了一个 bash 脚本,然后调用自己的方法来启动游戏就可以完成这项工作,但不幸的是,它的结果是一样的。

基本上,当我 运行 我的 linux GUI 中的 SAME EXACT 命令时,游戏开始没有问题,但是当我从远处 运行 我的 SAME EXACT 命令时SSH,游戏没有启动,只是卡在那里。

mono /home/pi/.../game/TestGame.exe

我正在 运行LinuxRaspbianraspberry PI。 我的 raspberry PI 在我的屏幕上已连接。当插入我的键盘时它会启动,当我从我的另一台计算机上使用 ssh 尝试时,它会崩溃并给出我们在此处看到的错误。

如有任何帮助,我将不胜感激。

非常感谢! 凯文

跟进我的发现,

如果您遇到此错误,请注意两件事:

  1. 检查您的 SSH 终端是否激活了 X11 转发。
  2. 输入这个神奇的行来告诉 SSH 使用哪个监视器。否则任何图形软件都会在启动时崩溃..

    导出显示=:0

谢谢, 凯夫