2013-10-01 40 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>用於聲明在該文件的頂部聲明模塊或命名空間內的子模塊。