备忘:.NET的CultureInfo

使用C#进行开发时如果碰到需要使用CultureInfo而又没有显示指定时(例如:DateTime的ToString,string.Format等)会发生什么呢?

  • Console程序:程序默认会从Thread.CurrentThread.CurrentCulture获取CultureInfo,而该CultureInfo来自执行程序的登录用户在控制面板中的地区和语言的配置。
  • WindowService
    • 如果该WindowService是以某个OS用户的身份运行的,则程序默认会读取该用户在地区和语言中的配置;
    • 如果该WindowService是以LocalSystem运行的,程序默认会从注册表的"HKEY_USERS/.DEFAULT/Control Panel/International"中获取;

引用自:

https://social.msdn.microsoft.com/Forums/vstudio/en-US/8fbca78b-5078-4a12-8abb-4051076febbb/c-windows-service-culture-info-problem

相关链接:

How does a .NET process get the culture information?

Default Culture in a Windows Service

Add the Log on as a service right to an account

ANSI Code Page for Windows System Locale with Identifier Constants and Strings

The .Default user is not the default user

posted @ 2015-12-16 15:57  RoyLiu  阅读(231)  评论(0编辑  收藏  举报