2013-10-01 33 views
0

我试图通过C#API连接到Interactive Brokers。作为练习,我试图在F#中开发我的客户端。在f#中使用c#库

这是我做了什么:

  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”或“模块SomeNamespace.SomeModule”

我用Google搜索周围的解决方案。我是一个完整的noob。 某些帖子引用了F#文件顺序,但在这种情况下,我正在使用C#库。

回答

0

这意味着您的文件必须以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>用于声明在该文件的顶部声明模块或命名空间内的子模块。