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

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