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

本文关键字:不支持 文化 异常 项目 Xamarin | 更新日期: 2023-09-27 18:14:05

刚刚下载了Xamarin Studio 5.9.6 (build 23),然后进入工具-选项-语言,选择"English"作为"用户界面语言"

当我创建一个新的c#"空项目"时,Xamarin抱怨说,一个对话框显示:"发生错误-无法创建项目"。

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 studio,包括VS2015。

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

这是Xamarin Studio在Windows 10上的语言选择错误。在Xamarin Studio 5.10中修复。

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

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

由于Xamarin Studio使用了无效的文化,这导致了f#异常。

现在Xamarin Studio 5.10及以上版本会忽略这些带有未指定自定义区域设置id的区域性

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

所以这个问题的快速修复是回到Xamarin工具-选项-语言,并将其更改回(默认)。

选择英文时用户错误(?)。