'System.Globalization.CultureNotFoundException' in System.Private.CoreLib.dll

Hi all,

I’m developping a game on .Net 10 and MonoGame 3.8.4.1.
In my game, I’m using .resx files to manage the translations.

I’m also using my own framework/engine : GitHub - Asthegor/DinaCSharp: Framework from MonoGame

Here the link to the code of the game: GitHub - Asthegor/Dungeon100Steps: La Grotte aux 100 Pas : Micro-RPG roguelite 2D. Explorez divers donjons linéaires générés par seed. Gérez vos ressources sur 100 cases de combats au tour par tour, pièges et événements narratifs. Progressez sans limite de niveau avec 3 classes uniques. Runs stratégiques de 20 min. Propulsé par MonoGame.

I encounter 670 exceptions while launching my game: ‘System.Globalization.CultureNotFoundException’ in System.Private.CoreLib.dll.

The game seems to work fine but I wanted to know:

  1. Am I the only one having this much of trace on the logs?
  2. How to get ride of those messages?

my guess would be you are using an invalid culture code. Can you list the culture codes you are using?

Because I had never received any messages when running my games until now, I assumed that my code was working perfectly.
After adding a few traces, I noticed that a try/catch was generating these lines.
With the help of Claude.AI, I changed the way the CultureInfo used was listed.

The code in comment below was the one generating the trace.

//{
//    var culture = new CultureInfo(cultureName);
//    var satellitePath = Path.Combine(directory, $"{assembly.GetName().Name}.resources.dll");
//    if (File.Exists(satellitePath))
//        cultures.Add(cultureName);
//}
//catch (CultureNotFoundException)
//{
//    // Ignore invalid folders but generate a trace...
//}
if (CultureInfo.GetCultures(CultureTypes.AllCultures).Any(c => c.Name.Equals(cultureName, StringComparison.OrdinalIgnoreCase)))
{
    var satellitePath = Path.Combine(directory, $"{assembly.GetName().Name}.resources.dll");
    if (File.Exists(satellitePath))
        cultures.Add(cultureName);
}
1 Like