F#模块/命名空间错误

Mic*_*cah 2 f#

我用F#的第一个程序.

我有一个这样的文件:

namespace LanguageMapper.Data


#if INTERACTIVE
#r "System.Data"
#r "System.Data.Linq"
#r "FSharp.Data.TypeProviders"
#endif

open System.Data
open System.Data.Linq
open Microsoft.FSharp.Data.TypeProviders

module Data = 

    // You can use Server Explorer to build your ConnectionString. 
    type SqlConnection = Microsoft.FSharp.Data.TypeProviders.SqlDataConnection<ConnectionString = @"connstring">
    let db = SqlConnection.GetDataContext()
Run Code Online (Sandbox Code Playgroud)

然后我有另一个这样的文件

namespace LanguageMapper.Program

open Data

module Program = 

[<EntryPoint>]
let main argv = 


    let getLocale x = 
        match x with
        | [|"live"|] -> "live"
        | [|"dev"|] -> "dev"
        | _ -> "local"
Run Code Online (Sandbox Code Playgroud)

open Data我的顶部,我在VS中得到一个红色的波浪形告诉我:

"错误1此声明通过部分限定的路径打开命名空间或模块'Microsoft.FSharp.Data'.调整此代码以使用命名空间的完整路径.此更改将使您的代码更加健壮,因为新的构造被添加到F#和CLI库."

我究竟做错了什么?我只想引用另一个文件.

Joh*_*lph 5

您需要使用其完全限定名称(包括其名称空间)打开模块.所以LanguageMapper.Program你需要open LanguageMapper.Data.Data(只有最后一位是模块名称).

编译器抱怨你的open定义,因为它只指定打开名为Data的命名空间或模块 - 它在Microsoft.FSharp.Data中找到一个,可能是因为Microsoft.FSharp命名空间有一些"自动"打开.