Hello everyone,
I noticed that the games I created with MonoGame 3.7 worked on all three PCs at my disposal, while the game I’m developing with MonoGame 3.8.1 doesn’t work on one of these PCs (when I run the executable, nothing happens). The three PCs are all up to date and running Windows 10. The game is based on a Cross-Platform (OpenGL) project.
Can you help me figure out where the problem may be?
Did you check that the executables stopped running in the task manager? Something we’ve run into with OpenGL monogame on windows is that sometimes SDL just takes ages to initialize on some PCs.
The executable doesn’t even appear for a fraction of a second in the Task Manager, neither in the Processes tab nor in the Details tab. When I start the executable, the “busy circle” appears for a moment next to the mouse pointer and nothing else, not even warnings of some kind.
Could some library be missing or something? Could there be something out of date?
Personally I have a general try/catch over Game.Run in my Program.cs where I output any Exception to some log file.
Most often when the release version just seems to do nothing I just missed to copy some file and the Exception should show that
(not best practice, but could give a quick hint about what’s going wrong)
The fact is that the same problem also occurs when creating a new project without adding a single line of code. On 2 PCs the classic window with the cornflower blue background appears, while on the third PC it does not appear.
If the game instantly exits, that means there was an exception thrown. There might be something useful if you log it, it’s currently nigh impossible to remotely figure out what’s going on without that information.
As an extra test, I created a new project and edited the Program.cs file like this:
System.IO.File.WriteAllText("test.txt", "something");
using var game = new test0.Game1();
game.Run();
On 2 PCs the “test.txt” file is created while on the third it is not.
The problem then occurs before my code runs, as if MonoGame can’t find something it needs.
I also tried editing the Program.cs file (after creating a new project) like this:
try
{
using var game = new test0.Game1();
game.Run();
}
catch(System.Exception e)
{
System.IO.File.WriteAllText("log.txt", e.ToString());
}
but on the third PC the game does not start and the “log.txt” file is not created.
You may be missing the .NET6 runtime components on the third machine.
Try publishing your game to a single install file - this bundles in everything that is required by the game into a single .exe file.
Assuming you are using Visual Studio and targetting a Release build:
[Menus] Build ----> Publish selection
Choose the option to create a single file.
I followed what you suggested, in particular I chose “Full” as “Distribution mode” and enabled the “Produce a single file” option. This way everything works correctly.
So, is this the procedure to follow?
According to the MonoGame documentation, it is not recommended:
SingleFilePublish
SingleFilePublish packages your game into a single executable file with all dependencies and content integrated.
While it sounds very convenient, be aware that it’s not magical and is in fact a hidden self-extracting zip archive. As such, it may make app startup take a lot longer if your game is large, and may fail to launch on systems where user permissions don’t allow extracting files (or if there is not enough storage space available).
We highly recommend not using it for better compatibility across systems.
Not using SingleFilePublish just means you’ll have a lot of files to zip up and send over to the other PCs, since the entirety of the .NET runtime will be in there as dll’s.
The other option is to tell your users to install the runtime from Microsoft’s website. FYI, both Steam and itch.io’s launcher do these checks and automatically install the necessary runtimes, so if you distribute through those it’s not that much of a problem.
Good. I think I’ll choose the “SingleFilePublish” option.
Thanks everyone for the tips.
I use it for my itch.io packages as I don’t want people to refuse the install when presented with the “You must install .Net6”.
I have not noticed a significant increase is start up time.
Oh, I did find that users have to change the permissions on the exe for linux and MacOS before running. I hae not found a way around this.
I agree.
What is strange is that on the PC where the game didn’t work, there was no message about having to install .net6.
However with the “SingleFilePublish” option I solved every problem.