爲什麼你設置x-en-US
文化?
設置是:使用資源文件
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
:
MyResourceManager.yourcountry-en-US.resx
我覺得x-en-US
不是有效的CultureInfo碼,應該是en-US
您在這裏有一個微軟的例子在那裏你可以註冊自定義文化並分配它們:
public static void Main()
{
// Create a custom culture for ru-US.
CultureAndRegionInfoBuilder car1 = new CultureAndRegionInfoBuilder("ru-US",
CultureAndRegionModifiers.None);
car1.LoadDataFromCultureInfo(CultureInfo.CreateSpecificCulture("ru-RU"));
car1.LoadDataFromRegionInfo(new RegionInfo("en-US"));
car1.CultureEnglishName = "Russian (United States)";
car1.CultureNativeName = "русский (США)";
car1.CurrencyNativeName = "Доллар (США)";
car1.RegionNativeName = "США";
// Register the culture.
try {
car1.Register();
}
catch (InvalidOperationException) {
// Swallow the exception: the culture already is registered.
}
// Use the custom culture.
CultureInfo ci = CultureInfo.CreateSpecificCulture("ru-US");
Thread.CurrentThread.CurrentCulture = ci;
Console.WriteLine("Current Culture: {0}",
Thread.CurrentThread.CurrentCulture.Name);
Console.WriteLine("Writing System: {0}",
Thread.CurrentThread.CurrentCulture.TextInfo);
}
在我的情況下,會產生一個'System.Globalization.CultureNotFoundException',並帶有其他信息:Culture不受支持 – Sjoerd222888