通过FSI使用COM DLL [英] Using COM DLLs with FSI

查看:71
本文介绍了通过FSI使用COM DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

FSI中是否可以引用和使用已注册的COM组件?

在普通的.fs编译程序中,我可以简单地引用有问题的组件,然后打开相关的生成的命名空间.但是,在.fsx文件中,我似乎无法复制这种行为.我尝试使用#r直接引用.dll,并且尝试使用#I指向#r后跟目录的库的友好"名称和文件名,但似乎无济于事.

您只能从.fsx引用.NET程序集吗?我真的不需要编写/生成包装程序集.我希望有一种方法可以迫使FSI采取常规可执行文件所采取的任何步骤以提供互操作层.

解决方案

在Visual Studio中添加对COM组件的引用时,它会调用一个工具来生成包装器(标准.NET程序集),然后引用该包装器.

如果要从fsx引用COM,则需要自己生成包装器(或找到由Visual Studio生成的包装器).生成包装器的工具称为TlbImp.exe(请参见 MSDN上的类型库导入器).

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.

解决方案

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).

这篇关于通过FSI使用COM DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆