F#4.0代码在交互式中运行,但在VS2015中无法编译

Luc*_*ier 1 f# visual-studio

我安装了以下内容:

  • Visual Studio 2015(包括F#4.0 /在"扩展和更新"选项卡中安装的列表)
  • F#4.0(也在PATH中设置)

以下行将无法在我的Visual Studio中编译:

List.contains 1 [1;2]

>> error FS0039: The value, constructor, namespace or type 'contains' is not defined
Run Code Online (Sandbox Code Playgroud)

但是在Powershell的FSI运行以及Visual Studio中的FSI运行良好.Powershell FSI和VS FSI也显示相同的F#Interactive版本号.

任何想法为什么它在交互式运行,但不编译?

mar*_*lam 6

检查项目属性页面,在第一个选项卡上,"Target F#Runtime"应设置为4.4.0.0.

如果已经存在,请检查您使用的NuGet包是否未添加对FSharp.Core 3.something的引用 - 如果有,则NuGet更新选项卡应提供版本4,因此请更新到该版本.

还要检查App.config是否未将FSharp.Core重新映射到4.3版本,否则您将收到有关缺少方法的奇怪运行时错误.