-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.NET misreports current culture after upgrading to .NET6 #60296
Comments
Yes it is easily fixed by adding
to my app's startup method but it shouldn't be necesarry and .NET should not be making up UI cultures that do not exist. |
@benvillalobos: Can you take a look? This may be related to dotnet/wpf#5381. |
Tagging subscribers to this area: @tarekgh, @safern Issue Details
Problem description: After upgrading from .NET 5.0.4 to .NET6 RC1 I run into a Expected behavior: .NET accurately identifies the culture info is either en-us or something that matches my locale.
|
@Joren-Thijs if you create a simple console app doing Console.WriteLine(CultureInfo.CurrentCulture)
Console.WriteLine(CultureInfo.CurrentUICulture) Compile and run it against .NET 5.0 and .NET 6.0 We are reading the UI culture from Windows and we didn't change this part. Also, could you please share the full stack of the exception you are getting? CC @safern |
I have mimicked the same settings mentioned by @Joren-Thijs and run the following code on both .NET 5.0 and .NET 6.0. I set the UI and user locales on the machine as Console.WriteLine($"CurrentCulture = {CultureInfo.CurrentCulture.Name}");
Console.WriteLine($"CurrentUICulture = {CultureInfo.CurrentUICulture.Name}");
Console.WriteLine($"{RegionInfo.CurrentRegion}"); and I am getting the exact same results on both cases:
@singhashish-wpf This looks more a WPF issue than the runtime issue. Did you have a chance to look at? |
Culture issue@tarekgh I have done what you asked and run the same code in both .net 5 and .net 6
In both cases it yields the same output:
So it appears there's either a deeper issue or a very isolated issue with my machine? I am once again going to include my system info below: Device Specifications
Windows Specifications
My language settings:Here under language settings i do see that my systems app language is Dotnet 5 info
Dotnet 6 info
WPFHowever I cannot answer why my WPF project only crashes on .NET 6 since the method that throws was a constructor for a CSV parser from this Filehelpers libary. (I have the latest version 3.5 installed) This method does not throw in .NET 5 which i find odd, even though it appears both .NET 5 and 6 misreport my current culture I have also grabbed the full exception from my log files:
|
Update: so i tried switching my app language in windows to en-US and now the reported culture is indeed
That just leaves me with the question why that code did not throw in net 5 but did throw in net 6? since i can manually set the culture to en-BE without .net crashing on me in my sample app. I'm going to investigate the library code and see if I can find any issues there. For now I am going to close this issue. If i find anything i will report it here. |
Thanks @Joren-Thijs for the info. I am seeing throwing on such case is the correct behavior. I am not sure either why this is not throwing on .NET 5.0. Something you may try is to print the value |
Here is the line that need to be fixed: This can be fixed by the code like: ci = new CultureInfo(CultureInfo.CurrentCulture.Name); |
Wow thats a lot of great info! Thank you! |
@tarekgh I have done some additional testing and did find a descrepancy between .net 5 en .net 6 When printing out the LCID for Here is my new test code where i do print out the LCID:
Net 5 output:
Net 6 output:
|
The behavior of .NET 6.0 is more correct. That is why we keep asking users to go away from LCID to avoid running into different issues. To give more info why I am saying .NET 6.0 is the correct behavior. The case you are running into getting the LCID
By the way, when I run your code on my machine with .NET 5.0 I am getting the following :-)
|
Again very useful info! Thank you! |
@tarekgh I read the document you included and it's starting to make sense to me. The LCID code is made up of three parts that together form a hex value. (See document) But it also quotes:
For context for people reading this who like me don't convert hex values on the daily😅 tarekgh's code of |
Problem description:
After upgrading from .NET 5.0.4 to .NET6 RC1 I run into a
{"Culture is not supported. (Parameter 'culture')\r\n4096 (0x1000) is an invalid culture identifier."}
exception. The culture reported here isen-be
(English-Belgium) which of course does not exist..NET is misreporting the current UI culture. My app is set to English, my Windows 10 is set to English, my keyboard is set to English (US International) but my region is set to Belgium where i live.
Expected behavior:
.NET accurately identifies the culture info is either en-us or something that matches my locale.
Note I do not have my native and regional language Dutch (be-nl) installed on this machine, nor have I had it installed on this machine before.
I only have
en-us
installed on my windows machine.The text was updated successfully, but these errors were encountered: