[英]Embed Interop Types in F#
Can we embed interop type in F# ? 我们可以在F#中嵌入interop类型吗?
First I dont see the option to do so in the references. 首先,我没有在参考文献中看到这样做的选项。
Second, if I embed the type in C#, it tells me to reference the interface and not the concrete class: 其次,如果我在C#中嵌入类型,它告诉我引用接口而不是具体类:
//DBEngine is the interface DBEngineClass is the concrete class
//if I dont embed the interop
//Valid
var dbe = new Microsoft.Office.Interop.Access.Dao.DBEngineClass();
//Valid
var dbe = new Microsoft.Office.Interop.Access.Dao.DBEngine();
//if I do embed the interop
//Invalid
var dbe = new Microsoft.Office.Interop.Access.Dao.DBEngineClass();
//Valid
var dbe = new Microsoft.Office.Interop.Access.Dao.DBEngine();
However, F# always wants to have a reference to the concrete class. 但是,F#总是希望引用具体类。 Is there a way around this ?
有没有解决的办法 ?
Maybe I don't understand your question, but this works fine, referencing v14.0: 也许我不明白你的问题,但这很好用,参考v14.0:
open Microsoft.Office.Interop.Access.Dao
let dbe = DBEngineClass() :> DBEngine
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.