【问题标题】:use c# library in f#在 f# 中使用 c# 库
【发布时间】:2013-10-01 13:10:48
【问题描述】:

我正在尝试通过盈透证券的 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 ​​库或多文件应用程序中的文件必须开始 带有命名空间或模块声明,例如'命名空间 SomeNamespace.SubNamespace' 或 'module SomeNamespace.SomeModule'

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

【问题讨论】:

    标签: c# f# libraries tws


    【解决方案1】:

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

    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>用于在文件顶部声明的模块或命名空间中声明子模块。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-01-04
      • 2016-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-05
      相关资源
      最近更新 更多