Trouble with Getting Started Guide for version 3.8.1.303

I’ve followed along with the latest getting started guide here:

https://docs.monogame.net/articles/getting_started/2_creating_a_new_project_vs.html

I started with a new install of VS2022, the required workload components and then proceeded to creating the example “Pong” project, from the “Cross-Platform Desktop template”.

It all goes well until I run the default program. No window appears, no Cornflower blue, just a program exit:

The program '[16560] PongVS2022.exe' has exited with code 3221226505 (0xc0000409).

I tried to debug the situation using the latest Git code and traced the issue to this file:

\MonoGame.Framework\Platform\SDL\SDL2.cs

Line 399:

public static IntPtr Create(string title, int x, int y, int w, int h, int flags)
{
    return GetError(SDL_CreateWindow(title, x, y, w, h, flags));
}

This gets called twice (before program crash). The first time is from:

\MonoGame.Framework\Platform\SDL\SDLGameWindow.cs constructor, line 132:

_handle = Sdl.Window.Create("", 0, 0,
                GraphicsDeviceManager.DefaultBackBufferWidth, GraphicsDeviceManager.DefaultBackBufferHeight,
                Sdl.Window.State.Hidden | Sdl.Window.State.FullscreenDesktop);

and this call completes without issue.

the second time is from the same classes CreateWindow method, on line 161:

_handle = Sdl.Window.Create(
                AssemblyHelper.GetDefaultWindowTitle(),
                winx, winy, _width, _height, initflags
            );

passing values:

title = "Pong"

x = 805240832
y = 805240832

w = 800
h = 480
flags = 1546

this is where the line:
return GetError(SDL_CreateWindow(title, x, y, w, h, flags));

causes the program to crash.

I’ve not modified the default program from the template in any way, this was all fresh out of the box. does anyone have any ideas what is going wrong here?

I suspect the issue may be with your machine, or more specifically your graphics card/drivers.

Just tested the instructions on a fresh machine, installed the MonoGame Extension, Created a Cross platform desktop app and run it, and this resulted in the expected Cornflower blue screen.

Can you try compiling the game on your machine and then running the exe on another machine (if you have one).

Alternatively, try using one of the other templates like the MonoGame Desktop or XAML templates and see if the result is the same.

SDL issues are generally with OpenGL driver issues on hosts, which do not generally come up unless there is an issue with the graphics driver.

Thank you Simon.

I’ll try to proceed with the drivers in mind.

Unfortunately i only have one pc but i have tried some of the other templates, dx, uwp xaml (and converted to a core app uwp as there is no template for that any more, perhaps i should raise an issue on github about that). All of which seem to work without issue.

I’m not new but i am new to this version and vs2022 so perhaps if i try an opengl project in a previous monogame version as it might throw some light on any opengl driver issues my machine might have.

If i find anything out I’ll be sure to report back here in case it may help anyone else starting out with monogame.

I have some additional information and a workaround/hack.

Info: Having just installed a new NVidia driver it occurred to me that my laptop actually has two graphics cards:

  1. Intel HD, used as a default everyday card
  2. An NVIDIA one (a GTX 1060)

I’ve noticed in the past how Monogame exe’s always default to use the Intel HD card, which is annoying but I can manually specify to use the NVIDIA one if needed. So I looked to see if there was a driver update for the Intel HD card:

IntelHD Driver
Answer: no.

These are the specs:

After googling I added this line/hack to my Program.cs file to try to force the program to use the NVIDIA card:

NativeLibrary.Load("nvapi64.dll");

And bingo: problem solved, now I get a windows and a Cornflower blue screen, as expected.

So I supposed that the Intel HD 630 card is just not compatible either with SLD2 or the way that monogame calls the SDL methods. I’m not sure if this is by design or an unexpected bug but some info or a heads up about the potential issue would be a great help, especially for a beginners tutorial that explicitly recommends starting with a DesktopGL type project.

2 Likes