I think it's better to prevent this error with a try...catch:
Unhandled exception. Microsoft.Xna.Framework.Graphics.NoSuitableGraphicsDeviceException: Failed to create graphics device!
---> System.NullReferenceException: Object reference not set to an instance of an object.
at MonoGame.OpenGL.GL.GetString(StringName name)
at MonoGame.OpenGL.GL.LoadExtensions()
at MonoGame.OpenGL.GL.LoadEntryPoints()
at MonoGame.OpenGL.GraphicsContext..ctor(IWindowInfo info)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.PlatformSetup()
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.Setup()
at Microsoft.Xna.Framework.Graphics.GraphicsDevice..ctor(GraphicsAdapter adapter, GraphicsProfile graphicsProfile, Boolean preferHalfPixelOffset, PresentationParameters presentationParameters)
at Microsoft.Xna.Framework.GraphicsDeviceManager.CreateDevice(GraphicsDeviceInformation gdi)
at Microsoft.Xna.Framework.GraphicsDeviceManager.CreateDevice()
--- End of inner exception stack trace ---
at Microsoft.Xna.Framework.GraphicsDeviceManager.CreateDevice()
at Microsoft.Xna.Framework.GraphicsDeviceManager.Microsoft.Xna.Framework.IGraphicsDeviceManager.CreateDevice()
at Microsoft.Xna.Framework.Game.DoInitialize()
at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior)
at Microsoft.Xna.Framework.Game.Run()
at LTW.Program.Main() in /home/runner/work/LTW-client/LTW-client/LTW/Program.cs:line 44
/home/runner/work/_temp/b23d8555-d18e-4640-b831-7b70b0e74f92.sh: line 1: 2187 Aborted (core dumped) LTW/bin/Debug/net5.0/linux-x64/LTW
Error: Process completed with exit code 134.
I think it's better to prevent this error with a
try...catch
: