Culture is suddenly not supported anymore on Azure web app

孤街醉人 提交于 2019-12-03 03:00:58
Shawn Steele - MSFT

Almost all of the new locales in Windows are not assigned explicit LCIDs - because there is not enough "room" for the thousands of languages in hundreds of countries problem. They all get assigned 0x1000.

In this case, I think a changing LCID to name might work for you:

country = new RegionInfo(new CultureInfo(cul.Name, false).LCID);

to just use the culture name:

country = new RegionInfo(cul.Name);

Of course, any other use of LCID would also need to recognize the culture name instead.

We actually recommend that RegionInfo be constructed with a full culture name since that is more explicit than just the region name.  RegionInfo has some properties that "depend" on the languages, such as the DisplayName. es-US and en-US provide Spanish or English strings for "United States", for example.

Hope that helps,

-Shawn

I confirm that these are new cultures that were just added in Azure App Service, and evidently it was done in a way that creating a RegionInfo fails. The simplest repro is:

var culture = new CultureInfo("en-HK", false).LCID;
var region = new RegionInfo(culture);

And that fails with:

Unhandled Exception: System.Globalization.CultureNotFoundException: Culture is not supported. Parameter name: culture 4096 (0x1000) is an invalid culture identifier. at System.Globalization.CultureData.GetCultureData(Int32 culture, Boolean bUseUserOverride) at System.Globalization.RegionInfo..ctor(Int32 culture)

We are investigating further. In the meantime, catching exceptions and ignoring cultures where that fail is the recommended workaround.

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