C# CultureInfo.GetCultures returns a (nearly) empty list

谁说胖子不能爱 提交于 2019-12-10 21:26:24

问题


Windows 8.1 Pro, Visual Studio 2013, .NET Framework 4.5.2

Here is the code:

var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);
Console.WriteLine("Culture count: " + cultures.Length);

Here is the output:

Culture count: 2

The two cultures are zh-CHS and zh-CHT which are added in the CultureData.GetCultures method. The other cultures are supposed to be returned by CultureData.nativeEnumCultureNames but it appears that this is returning an empty array.

This behavior appears to be limited to a single workstation. I've tried the same code on other computers and am getting normal results. How would I go about fixing this? I've attempted re-installing the .NET framework with no success.

Edit 1: This only affects .NET 4/4.5. If my project targets .NET 3.5, it works, returning 311 cultures.


回答1:


Check to see if the key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\ExtendedLocale is present. If it is missing, there is a known issue that can be worked around by adding this key.



来源:https://stackoverflow.com/questions/25414693/c-sharp-cultureinfo-getcultures-returns-a-nearly-empty-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!