Xamarin C# 空项目异常:不支持文化

Xamarin C# empty project exception: Culture not supported

刚刚下载了Xamarin Studio 5.9.6 (build 23),进入工具-选项-语言,选择"English"作为"User interface language"。

当我创建一个新的 C# "empty project" 时,Xamarin 抱怨说,一个对话框显示:"An error has occurred - The project could not be created"。

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: 
The type initializer for 'Microsoft.FSharp.Compiler.SourceCodeServices.FSharpChecker' threw an exception. ---> System.TypeInitializationException: 
The type initializer for '<StartupCode$FSharp-Compiler-Service>.$Service' threw an exception. ---> System.TypeInitializationException: 
The type initializer for '<StartupCode$FSharp-Compiler-Service>.$Reactor' threw an exception. ---> System.Globalization.CultureNotFoundException: Culture is not supported.

Parameter name: culture
4096 (0x1000) is an invalid culture identifier.

有点奇怪的小烦恼。 运行 Windows 10 x64。我在这台电脑上也有很多 Visual Studios,包括 VS2015。

这个错误的有趣之处在于它抱怨 F# 编译器。然而,我的意图是创建一个新的 C# 空项目。 ...并且由于我的 Visual Studio 个实例,我确实加载了 F#。而且我在美国,这不像是我试图加载不同的语言。

因此,快速解决此问题的方法是返回到 Xamarin 工具 - 选项 - 语言,并将其改回(默认)。

用户错误 (?) 选择英语。

这是 bug Xamarin Studio 的语言选择 Windows 10。它已在 Xamarin Studio 5.10 中修复。

这通常在选择英语时看到,通常这将通过 Windows 10 使用非英语语言完成,并且将 Xamarin Studio 配置为使用英语不会更改 UI 文本但仍会显示 Windows.

使用的语言

问题是在 Windows 10 上,许多从 CultureInfo.GetCultures 返回的英语非中性文化有一个未指定的自定义区域设置 ID (LCID),即 0x1000。 Windows 的早期版本没有这个问题。其中一种文化被用于设置当前 UI 文化,但由于无效而被忽略。根据 Windows 之前的 MSDN 文档,10 个未指定的自定义区域设置 ID 已分配给用户创建的自定义区域性。在 Windows10 中,这个未指定的自定义区域设置 ID 被分配给没有唯一区域设置标识符且没有完整系统提供数据的任何文化。因此 Windows 10 returns 个具有此未指定语言环境 ID 的语言环境。

由于 Xamarin Studio 使用了无效的区域性,这导致了 F# 异常。

现在 Xamarin Studio 5.10 及更高版本将忽略这些具有未指定自定义区域设置 ID 的区域性。