Windows [BUG][solved] Game won't load

ordinaryfarmer

Greenhorn
Hello,

the game (Steam) won't load anymore. I don't even see any loading/startup screen. Here's the error log

Code:
Message: Sequence contains no elements
InnerException:
Stack Trace:    at System.Linq.ThrowHelper.ThrowNoElementsException()
   at System.Linq.Enumerable.Last[TSource](IEnumerable`1 source)
   at StardewValley.Options.setToDefaults() in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\Options.cs:line 606
   at StardewValley.Game1.Initialize() in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\Game1.cs:line 1795
   at StardewValley.GameRunner.AddGameInstance(PlayerIndex player_index) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\LocalMultiplayer.cs:line 891
   at StardewValley.GameRunner.Initialize() in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\LocalMultiplayer.cs:line 770
   at Microsoft.Xna.Framework.Game.DoInitialize() in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\MonoGame.Desktop\MonoGame.Framework\Game.cs:line 841
   at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\MonoGame.Desktop\MonoGame.Framework\Game.cs:line 465
   at StardewValley.Program.Main(String[] args) in C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\Program.cs:line 175

Game Version: 1.5.6 Hotfix #3
SDK Helper: SteamHelper
Game Language: en
GPU: AMD Radeon RX 6800 XT
OS: Win32NT Microsoft Windows NT 10.0.19044.0
My sytsem is up to date. Recent graphics drivers are installed (AMD Radeon 22.7.1). Switching to 32Bit doesn't help. The game worked flawlessly just some months ago.

According to Options.cs some display modes are loaded in setToDefaults function

Code:
  preferredResolutionX = GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.Last().Width;
  preferredResolutionY = GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.Last().Height;
The error messages tells something about "no elements". It seems like GraphicsAdapter.DefaultAdapter.SupportedDisplayModes returns an empty set and therefore there isn't any Last() element, which leads to the error shown in the log.

I'm thankfull for any help.

EDIT: I have NO mods installed. I also checked these points
  • Delete the startup_preferences folder in %AppData%/StardewValley
  • Make sure you have .NET 5.0+ installed (i've installed the current 6.04 version)
  • Lauch options are ampty
 
Last edited by a moderator:

ordinaryfarmer

Greenhorn
Installed recent gpu drivers and completely reinstalled the game through steam. It still won't launch. Getting the same error log.
 

UlyanaLeyana

Planter
EDIT: I have NO mods installed. I also checked these points
  • Delete the startup_preferences folder in %AppData%/StardewValley
  • Make sure you have .NET 5.0+ installed (i've installed the current 6.04 version)
  • Lauch options are ampty
Are you using dual monitors?
The problem is that the game can't catch your screen resolution and won't launch for that reason.
I found several solutions that helped users, maybe one of them will work for you.
Users had issues with AMD graphics drivers, display drivers, more than one monitor, dual monitors, laptop+monitor, 2 graphic cards (one was integrated) , 2nd monitor isn't displaying proper resolution, DirectX...
Two of them had the same GPU as yours (maybe you are one of?:D) one two

  1. Reinstall Microsoft XNA Framework
  2. Update Monitor Display Driver
  3. Clean graphics driver reinstalling
  4. Reinstall DirectX
  5. CRU software (to reset resolution, check how to use it)
  6. Try to use someone's startup_preferences
 
Last edited:

ordinaryfarmer

Greenhorn
Nope, not using dual monitors. I do own an Index VR, but checked if it is listed as device under screens, despite being off. Also tried all your points besides number 5. Recently new AMD drivers came out and i installed them (22.9.1). Still the game won't launch and i get the same error. The game (or XNA?) has seemingly trouble to get my screen resolution.

Windows Forms is capable of reading my screen size

C#:
void Main()
{
    Console.WriteLine(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width);
}
returns 2560. I think there's some Issue with XNA Framework. I'm not into XNA and i don't know how to write a little test snippet of csharp code, to test it myself. Something like
C#:
using Microsoft.Xna;
immediately leads to an error. Do i have to install Visual Studio and XNA Game Studio? I guess the xnafx_40_redist (which i installed) is just for running XNA applications, not building them? I'm currently not familiar with C#. I guess "redist" installs something like "so" (shared object) files under Linux?
 

ordinaryfarmer

Greenhorn
Tried it. Chose "high performance". The Option listed my GPU correctly: AMD Radeon 6800 XT. Still no luck. I got the exact same error in the log file. Anyway, thank you very much for your help.
 

ordinaryfarmer

Greenhorn
Ok got it. I've even installed VS 2022 and did some tricks to get XNA running. Tested the following code
C#:
namespace Project1
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        public static GraphicsDeviceManager graphics;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
        }

        public GraphicsDeviceManager getGraphicsDeviceManager()
        {
            return graphics;
        }
    }
}
and
C#:
namespace Project1
{
    internal class Class1
    {
        public static Game1 game1;

        static void Main() {
            game1 = new Game1();
            Console.WriteLine("Device Test: ");
            Console.WriteLine(game1.GetType());
            Console.WriteLine(game1.getGraphicsDeviceManager().GetType());

            if (game1.getGraphicsDeviceManager().GraphicsDevice == null)
            {
                Console.WriteLine("No graphics device found!");
            }
            else
            {
                Console.WriteLine(game1.getGraphicsDeviceManager().GraphicsDevice.GetType());
            }
        }
    }
}
and got "No graphics device found!". Then i thought "hm, Terraria uses XNA too ..." and guess what. Same problem! Just got a black screen. In fact it completely turned off! And that's where i got the idea. For some reason, XNA tries to use my Index VR as device despite being powered off! It's not even listed as screen in Windows device settings. So i disconnected the headset and voila, the game is running! Also Terraria works. I had a similar Issue with Xcom 2. Now this game also runs fine.

So i highly suspect, some AMD driver update confuses now some libraries in finding the primary screen if you use Index VR even if its turned off. The GPU has two dsiplay ports, so now i think one port is strictly considered as primary screen even if the device is turned off.
 

UlyanaLeyana

Planter
Ok got it. I've even installed VS 2022 and did some tricks to get XNA running. Tested the following code
C#:
namespace Project1
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        public static GraphicsDeviceManager graphics;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
        }

        public GraphicsDeviceManager getGraphicsDeviceManager()
        {
            return graphics;
        }
    }
}
and
C#:
namespace Project1
{
    internal class Class1
    {
        public static Game1 game1;

        static void Main() {
            game1 = new Game1();
            Console.WriteLine("Device Test: ");
            Console.WriteLine(game1.GetType());
            Console.WriteLine(game1.getGraphicsDeviceManager().GetType());

            if (game1.getGraphicsDeviceManager().GraphicsDevice == null)
            {
                Console.WriteLine("No graphics device found!");
            }
            else
            {
                Console.WriteLine(game1.getGraphicsDeviceManager().GraphicsDevice.GetType());
            }
        }
    }
}
and got "No graphics device found!". Then i thought "hm, Terraria uses XNA too ..." and guess what. Same problem! Just got a black screen. In fact it completely turned off! And that's where i got the idea. For some reason, XNA tries to use my Index VR as device despite being powered off! It's not even listed as screen in Windows device settings. So i disconnected the headset and voila, the game is running! Also Terraria works. I had a similar Issue with Xcom 2. Now this game also runs fine.

So i highly suspect, some AMD driver update confuses now some libraries in finding the primary screen if you use Index VR even if its turned off. The GPU has two dsiplay ports, so now i think one port is strictly considered as primary screen even if the device is turned off.
I thought that the problem would be in the use of an additional device. It was not a second monitor, not a second graphic card, not a laptop... it was an Index VR. It wasn't enough to just turn it off. :cat:
It's good that the error has been fixed.
 
Top