CurrentCulture 在 DNX Core 5.0 中不可用

CurrentCulture Not Available in DNX Core 5.0

我在使用 Visual Studio 2015 RC 14.0.22823.1 D14REL 的最新 (5/1/2015) 版本诊断依赖性问题时遇到问题。

以下代码未编译并抛出此错误:

Severity    Code    Description Project File    Line
Error   CS1061  
'Thread' does not contain a definition for 'CurrentCulture' and no 
extension method 'CurrentCulture' accepting a first argument of type 
'Thread' could be found (are you missing a using directive or an assembly
reference?) 
ServiceLibrary.DNX Core 5.0 


using System;
using System.Globalization;
using System.Threading;

namespace ServiceLibrary
{
    public class CultureService
    {
        public void SetCulture(string cultureCode = "fr-FR")
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo(cultureCode);
        }
    }
}

将鼠标悬停在 CultureInfo Visual Studio 上会显示一个弹出窗口,其中显示:

这里是 project.json

{
  "version": "1.0.0-*",
  "description": "",
  "authors": [ "" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",

  "dependencies": {
    "System.Threading": "4.0.10-beta-22816",
    "System.Threading.Thread": "4.0.0-beta-22816",
    "System.Globalization": "4.0.10-beta-22816"
  },

  "frameworks": {
    "dnx451": { },
    "dnxcore50": {
      "dependencies": {
        "System.Collections": "4.0.10-beta-22816",
        "System.Linq": "4.0.0-beta-22816",
        "Microsoft.CSharp": "4.0.0-beta-22816",

      }
    }
  }
}

希望有人帮忙看看问题出在哪里

谢谢

文化命名空间位于 DNCCORE50 和成熟的 DNX451 之间的不同位置,因此您必须使用编译器指令。希望这有帮助。

#if DNX451
            Thread.CurrentThread.CurrentCulture = new CultureInfo(cultureCode);
#elif DNXCORE50
            CultureInfo.CurrentCulture = new CultureInfo(cultureCode);
#else
#error No Implementation for the target DNX 
#endif