Monogame Launches Two Windows On Windows OS

I’ve come across a rather strange problem that only seems to occur when Monogame .exe’s are run on Windows. It doesn’t happen with executables on MacOS. When you click on the .exe it creates a black window that has the path to the exe written on it and it also opens the game’s window. I’ve verified this with multiple games. If you close the black window it will also close the game’s window. Does anyone know how to prevent this from happening? I’d like to just have the game window open when the .exe is clicked on.

1 Like

I figured out the solution to this bizarre problem. If you are in Visual Studio for Mac and do a “dotnet publish -r win-x64” to publish a Windows version, the published .exe will run perfectly on a Windows box EXCEPT it launches an extra black window for unknown reasons. I decided to download my solution to my Windows box and ran “dotnet publish -r win-x64” in Visual Studio 2019 for Windows and the .exe it creates does not create the extra black window. Now I know that I better publish the Windows version of my games on Visual Studio for Windows to avoid this problem.

I don’t know what I’m talking about, but it sounds to me like VS for Mac is building it as a console application (the black window is a Command Prompt window, the equivalent of a Terminal window on Mac or Linux).

That’s probably what it’s doing. However, when dotnet publish -r win-x64 is run on a Mac, Visual Studio for Mac should build the exact same executable as it would when running dotnet publish -r win-x64 on a Windows version of Visual Studio. I’m racking this one up as a Visual Studio for Mac bug.

i have the same problem in vs 2022 for mac in windows and mac

It’s an issue with dotnet publish on non Windows platforms. You can read more about it here:

Not sure if this is related (and I am on an older version of MG) but when I run the game in fullscreen and alt-tab to see the open windows, there is a black window displayed next to the actual game window in the open tasks … but yea, older version, so maybe this exact issue for me is already solved - just in case it’s related somehow and helpful for finding out.