- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们使用 CultureInfo(customCulture) 将文化设置为自定义文化
为了以防万一,我们在 app_start 的 global.cs 中创建了 customCulture。
在我的本地 PC 上,这工作正常。但是在网络服务器上,当我去设置文化时,我得到了不支持文化的错误?我检查了 Windows\Globalization 文件夹,那里有一个文化文件用于正确的文化?
同样的代码在 3.5 下运行良好?
最佳答案
为了防止其他人遇到这个问题,我不得不编写一个命令行工具来注销文化,然后重新注册。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
namespace InstallCulture
{
class Program
{
static void Main(string[] args)
{
// Is CustomCulture already installed?
string parentCultureName = "en-GB";
string extendedName = "custom";
System.Globalization.CultureInfo[] userCultures = System.Globalization.CultureInfo.GetCultures(System.Globalization.CultureTypes.UserCustomCulture);
Console.WriteLine(string.Format("number of user cultures:{0}", userCultures.Count()));
Console.WriteLine(string.Format("Setting culture {0}-{1}", parentCultureName, extendedName));
// Install CustomCulture based on language parent.
System.Globalization.CultureAndRegionInfoBuilder builder = new System.Globalization.CultureAndRegionInfoBuilder(
string.Format("{0}-{1}", parentCultureName, extendedName),
System.Globalization.CultureAndRegionModifiers.None);
builder.LoadDataFromCultureInfo(new System.Globalization.CultureInfo("en-GB"));
builder.LoadDataFromRegionInfo(new System.Globalization.RegionInfo("GB"));
Console.WriteLine("CultureName:. . . . . . . . . . {0}", builder.CultureName);
Console.WriteLine("CultureEnglishName: . . . . . . {0}", builder.CultureEnglishName);
Console.WriteLine("CultureNativeName:. . . . . . . {0}", builder.CultureNativeName);
foreach(System.Globalization.CultureInfo cultInfo in userCultures)
{
Console.WriteLine("Found culture in userCultures");
if(cultInfo.Name.ToLower() == string.Format("{0}-{1}", parentCultureName, extendedName).ToLower())
{
Console.WriteLine(string.Format("{0} already registered", cultInfo.Name));
CultureAndRegionInfoBuilder.Unregister("en-GB-custom");
Console.WriteLine("Unregistered culture en-GB-custom");
}
}
Console.WriteLine("Registering culture en-GB-PolHol");
builder.Register();
Console.WriteLine("Create new culture info object");
System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("en-GB-custom");
Console.WriteLine("Name: . . . . . . . . . . . . . {0}", culture.Name);
Console.WriteLine("EnglishName:. . . . . . . . . . {0}", culture.EnglishName);
Console.WriteLine("NativeName: . . . . . . . . . . {0}", culture.NativeName);
Console.WriteLine("Set threads to new culture");
System.Threading.Thread.CurrentThread.CurrentCulture = culture;
System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
Console.WriteLine("Set culture done");
}
}
}
关于c#-4.0 - CultureNotFoundException : Culture is not supported after upgrading to . 净 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5094973/
嗨,我在 Chrome 中遇到了一个问题。我不知道这是我的代码错误还是chrome错误。错误是 加载资源失败:net::ERR_CONNECTION_CLOSED 我的QSTNURL是 const a
在小数点分隔符为的语言中,(逗号)CSV(逗号分隔值文件格式)分隔符为; (分号)。我知道在Windows控制面板中的哪里可以找到此配置,但是我不知道如何在.NET应用程序中以编程方式找到它。 我猜T
我在 2 个不同的服务器上托管了 2 个 RoR Web 应用程序。对于一个特定页面,请求由第二个应用程序提供。对于其余页面,请求由主应用程序提供。 主应用程序的 Nginx 设置 location
我尝试在失败时打印“错误IP USER PASS Failed!”。 当我使用脚本时 use Net::Telnet (); my $t = new Net::Telnet Timeout =
我已经开始在基于wordpress的项目中遇到问题。这个问题很奇怪。 这里是描述:当我在网站上搜索任何以字母d开头的内容时,它都可以正常工作-但是当搜索以字母d开头的内容时,我得到了Error 324
我正在尝试更改 pdftable 上的字体,并且我在 java 中有此提示,但需要一些帮助才能将其放入 vb.net PdfPTable table = new PdfPTable(3);
你好所以我做了 rest wcf 并尝试完成一些对象调用并在它返回对象列表后我得到消息: GET http://localhost/ESService/ESService.svc/GetExecuti
最近我们迁移到了新服务器。 2天后,我遇到了以下问题 1) 我们在 session 表上发生了崩溃,我们很容易通过修复它来修复它 2) 我们运行 OpenX 作为我们的广告服务器,它也崩溃了,但在 e
我最近开始自学 C# 和 Asp.net。我正在尝试构建一个简单的博客应用程序。我对存储库模式的使用感到困惑。我看过的教程很少,实现方式各不相同。 对于我的博客应用程序,我有两个数据库表(模型)——博
我想知道这两者之间的区别(对不起,我不知道这个主题的名称)。 我来自 C#,在那里我习惯于编写 System.data 以及 classA.MethodA。我已经发现在 Cpp 中,我需要使用::和类
我有一个带有 Webview 的 Electron 应用程序。当我将 webview src 设置为网站时 https://www.zap.co.il 我收到错误:net:ERR_CONNECTION
我有一个非常简单的 php 页面(CentOS 5.11 上的 PHP 5.5.35)查询 MySQL 数据库。结果页面显示完整,包括我作为最终说明包含的页脚,因此 PHP 脚本运行完全没有错误。几乎
我在 REST API 服务器上工作,该服务器的功能之一是能够在创建新资源或修改现有资源时通过 websocket 通知任意数量的客户端。 我有一个自定义操作路由器,用于将 URL 绑定(bind)到
我遇到了一个问题,快把我逼疯了。简而言之,我已经在纯 HTML/CSS 中本地测试了 subj 中的方法,它运行良好: 但是尝试
我们使用 CultureInfo(customCulture) 将文化设置为自定义文化 为了以防万一,我们在 app_start 的 global.cs 中创建了 customCulture。 在我的
我在玩代码,测试东西..一切正常,但在我刷新页面后,一切都开始“奇怪”了 这是 admin.aspx 中的代码: Dashboard Doctors 以及那些的CSS代码: #Le
经过漫长的一天,我终于查明了我认为是服务器不支持最新和最好版本的 SSL/TLS 密码协商问题。 堆栈: Ubuntu 14.04 完全修补 OpenSSL 1.0.1f 2014 年 1 月 6 日
我试图从我的操作中返回 Json,然后 IE 尝试下载它并显示保存对话框。我在 Firefox 中对其进行了测试,它运行良好。 return Json(new { success = false, m
如果出现连接/代理错误,我正在尝试重试请求。由于某些原因,我不断收到此错误,无论尝试重试请求,该错误似乎都无法恢复: Post https://m.somewebsite.co.uk/api/
我正在尝试转换此查询(已经工作): Select building.Name, Count(people.ID) as NumberOfUser From tblBuilding as buildin
我是一名优秀的程序员,十分优秀!