0

我正在尝试通过他们的 C# API 连接到盈透证券。作为练习,我正在尝试在 F# 中开发我的客户端。

这就是我所做的:

  1. 我已经在 Visual Studio 中导入了 CSharpAPI 项目。CSharpAPI 定义了 IBApi 命名空间
  2. 我在解决方案中创建了一个新的 F# 项目。该项目将主持我的实施
  3. 我在 .fs 文件中创建了一个新模块,如下所示:

    open IBApi
    
    module ibConnectivity =
    
       type IBclient =
           interface EWrapper with
           member this.connectionClosed() = printfn "connection has been closed"
           member this.currentTime time = printfn "server time: %i" time
    ....
    

我收到以下错误消息:

错误 1 ​​库或多文件应用程序中的文件必须以命名空间或模块声明开头,例如 'namespace SomeNamespace.SubNamespace' 或 'module SomeNamespace.SomeModule'

我已经用谷歌搜索了一个解决方案。我是一个完整的菜鸟。有些帖子提到了 F# 文件顺序,但在这种情况下,我正在使用 C# 库。

4

1 回答 1

0

这意味着您的文件必须以namespaceormodule声明开头。像这样:

module ibConnectivity

open IBApi

type IBclient =
    interface EWrapper with
    member this.connectionClosed() = printfn "connection has been closed"
    member this.currentTime time = printfn "server time: %i" time

该语法module Name = <indented declarations>用于在文件顶部声明的模块或命名空间内声明子模块。

于 2013-10-01T13:48:42.353 回答