C#CultureInfo.GetCultures返回(近)空单CultureInfo、GetCultures

由网友(哥是痴情范儿)分享简介:的Windows 8.1专业版时,Visual Studio 2013,.NET框架4.5.2 Windows 8.1 Pro, Visual Studio 2013, .NET Framework 4.5.2下面是code:var cultures = CultureInfo.GetCultures(Cultu...

的Windows 8.1专业版时,Visual Studio 2013,.NET框架4.5.2

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

下面是code:

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

下面是输出:

Culture count: 2

这两种文化是其被添加在 CultureData.GetCultures 法ZH-CHS和zh-CHT。其他文化都应该由 CultureData.nativeEnumCultureNames 返回但现在看来,这是返回一个空数组。

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.

此行​​为似乎仅限于一台工作站。我试过其他计算机上的相同code和我得到正常的结果。我将如何去修复呢?我试图重新安装,但没有成功。NET框架。

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.

修改1:这只会影响.NET 4.0 / 4.5。如果我的项目面向.NET 3.5,它的工作原理,并返回311文化。

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

推荐答案

请检查注册表项HKEY_LOCAL_MACHINE 系统 CurrentControlSet 控制 NLS ExtendedLocale是present。如果缺少,存在已知问题可以通过添加此键周围的工作。

Check to see if the key HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlNlsExtendedLocale is present. If it is missing, there is a known issue that can be worked around by adding this key.

阅读全文

相关推荐

最新文章