Using COM DLLs with FSI

為{幸葍}努か 提交于 2020-01-16 08:16:14

问题


Is there a way within FSI that I can reference and use registered COM components?

In a normal .fs compiled program I can simply reference the component in question and then open the relevant generated namespace(s). In a .fsx file, however, I can't seem to replicate this behaviour. I have tried using #r to reference the .dll directly, and I have tried using #I to point to the directory followed #r both with the library's "friendly" name and the file name, but nothing seems to work.

Are you only able to reference .NET assemblies from a .fsx? I don't really want to have to write/gen a wrapper assembly. I am hoping there might be a way to force FSI to take whatever steps the normal executable takes in order to provide the interop layer.


回答1:


When you add a reference to a COM component in Visual Studio, it invokes a tool to generate a wrapper (standard .NET assembly) and then references the wrapper.

If you want to reference COM from fsx, you'll need to generate the wrapper yourself (or find the one generated by Visual Studio?) The tool that generates the wrapper that is called TlbImp.exe (see Type Library Importer on MSDN).



来源:https://stackoverflow.com/questions/5407669/using-com-dlls-with-fsi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!