繁体   English   中英

在f#中使用c#库

[英]use c# library in f#

我正在尝试通过其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#库。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM