简体   繁体   中英

F# 4.0 code runs in interactive but doesn't compile in VS2015

I installed the following:

  • Visual Studio 2015 (including F# 4.0 / listed under installed in Extensions and Updates tab)
  • F# 4.0 (also set in PATH)

The following line won't compile in my Visual Studio:

List.contains 1 [1;2]

>> error FS0039: The value, constructor, namespace or type 'contains' is not defined

But is running fine in the FSI run on Powershell, aswell as the FSI in Visual Studio. Powershell FSI and VS FSI also show the same F# Interactive version number.

Any ideas why it runs in interactive, but doesn't compile?

Check the project properties page, on the first tab the "Target F# Runtime" should be set to 4.4.0.0.

If it is already, check that a NuGet package you've used hasn't added a reference to FSharp.Core 3.something - if it has, the NuGet updates tab should offer version 4, so update to that version.

Also check that the App.config isn't remapping FSharp.Core to the 4.3 version otherwise you'll get a strange runtime error about missing methods.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM