Startup crash associated with a DateTime parsing error
Here is the relevant part of the logs:
[22:33:15 ERR] Game initialization failed. We're about to exit.
[22:33:15 ERR] System.AggregateException: One or more errors occurred. (String '07/25/2024 20:19:04' was not recognized as a valid DateTime.)
---> System.FormatException: String '07/25/2024 20:19:04' was not recognized as a valid DateTime.
at System.DateTimeParse.Parse(ReadOnlySpan`1 s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
at System.DateTime.Parse(String s)
at SociallyDistant.Core.Modules.PlayerInfo.GetElement(XmlElement parent, String elemName, DateTime& field) in /var/lib/gitlab-runner/builds/GnB5jnxfw/0/sociallydistant/sociallydistant/src/SociallyDistant.Framework/Modules/PlayerInfo.cs:line 134
at SociallyDistant.Core.Modules.PlayerInfo.TryGetFromXML(String xml, PlayerInfo& info) in /var/lib/gitlab-runner/builds/GnB5jnxfw/0/sociallydistant/sociallydistant/src/SociallyDistant.Framework/Modules/PlayerInfo.cs:line 98
at SociallyDistant.GamePlatform.LocalGameData.LoadPlayerData() in /var/lib/gitlab-runner/builds/GnB5jnxfw/0/sociallydistant/sociallydistant/src/SociallyDistant/GamePlatform/LocalGameData.cs:line 97
at SociallyDistant.GamePlatform.LocalGameData.TryLoadFromDirectory(String directory) in /var/lib/gitlab-runner/builds/GnB5jnxfw/0/sociallydistant/sociallydistant/src/SociallyDistant/GamePlatform/LocalGameData.cs:line 113
at SociallyDistant.GamePlatform.LocalGameDataSource.CreateContent()+MoveNext() in /var/lib/gitlab-runner/builds/GnB5jnxfw/0/sociallydistant/sociallydistant/src/SociallyDistant/GamePlatform/LocalGameDataSource.cs:line 16
at SociallyDistant.GamePlatform.ContentManagement.ContentManager.<>c__DisplayClass13_0.<RefreshContentDatabaseAsync>b__0() in /var/lib/gitlab-runner/builds/GnB5jnxfw/0/sociallydistant/sociallydistant/src/SociallyDistant/GamePlatform/ContentManagement/ContentManager.cs:line 71
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at SociallyDistant.GamePlatform.ContentManagement.ContentManager.RefreshContentDatabaseAsync() in /var/lib/gitlab-runner/builds/GnB5jnxfw/0/sociallydistant/sociallydistant/src/SociallyDistant/GamePlatform/ContentManagement/ContentManager.cs:line 67
at SociallyDistant.SociallyDistantGame.InitializeAsync() in /var/lib/gitlab-runner/builds/GnB5jnxfw/0/sociallydistant/sociallydistant/src/SociallyDistant/SociallyDistantGame.cs:line 281
--- End of inner exception stack trace ---
This occured when I created a new save, closed the game, and then tried to start it again. It happens on subsequent attempts to start it as well.
The DateTime string that it's trying to parse is 07/25/2024 20:19:04
, which is in the month-day-year format. My system locale uses the day-month-year format. I suspect that the code calling DateTime.Parse
incorrectly does not set a locale, causing it to default to the system one. This likely causes a mismatch with the code responsible for saving this string, which probably does set a locale.
Assuming this hypothesis is correct, this should be solved by setting a locale in the relevant part of the code.
Edited by Ashe