简体   繁体   English

如何从LabView 6.1 VI调用.Net DLL?

[英]How can I invoke a .Net DLL from a LabView 6.1 VI?

I work in a manufacturing company that uses LabView for testing the devices we make. 我在一家使用LabView测试我们制造的设备的制造公司工作。 Most of the test engineers are using 7.1 which can natively reference a .Net assembly. 大多数测试工程师使用的是7.1,可以直接引用.Net程序集。 However, there is a group that is stuck on LabView 6.1. 但是,LabView 6.1上有一个组。 I would like for them to be able to use my .Net assembly which is basically a proxy to some web services. 我希望他们能够使用我的.Net程序集,该程序集基本上是某些Web服务的代理。

I have created a test assembly that is nothing more than Hello World, and I'm trying to consume it in a VI. 我创建了一个只不过是Hello World的测试程序集,并且试图在VI中使用它。 I made it COM visible, and registered it with regasm.exe and created a type library, which I'm not sure I need. 我将其显示为COM,并在regasm.exe中进行了注册,并创建了一个类型库,我不确定是否需要。 I can see it in Visual Studio in the list of COM objects when I open the Add Reference window, so I know it's registered properly. 当我打开“添加引用”窗口时,可以在Visual Studio的COM对象列表中看到它,因此我知道它已正确注册。

I'm very unfamiliar with VI's. 我对VI很陌生。 I'm only looking at it because no one I have spoken to in manufacturing knows anything about invoking a COM object in a VI. 我之所以只看它,是因为在制造业中与我交谈过的人都不知道有关在VI中调用COM对象的任何知识。 I'm basically looking for some names of controls or menu options to get the test engineers pointed in the right direction. 我基本上是在寻找控件或菜单​​选项的名称,以使测试工程师指向正确的方向。

I did a bunch of web searching on Google and the NI forums, but didn't find much. 我在Google和NI论坛上进行了一堆网络搜索,但没有发现太多。

Alternatively, would it be easier to write a C or C++ DLL that acts as a proxy to my .Net DLL? 或者,编写充当我的.Net DLL代理的C或C ++ DLL会更容易吗? Or is there a simple way to invoke a web service from a VI? 还是有一种简单的方法可以从VI调用Web服务? That might obviate the need for a DLL altogether. 这可能完全消除了对DLL的需要。

I'm currently reading through this document from NI for help, but it obviously knows nothing about .Net and might not be able to help me choose the best path forward. 我目前正在阅读NI的这份文档,以寻求帮助,但是它显然对.Net一无所知,并且可能无法帮助我选择最佳的前进道路。

Wow, LabView 6.1! 哇,LabView 6.1! A great release, but unsupported for 8 or more years now. 很好的发行版,但至今已有8年或更长时间不受支持。 I think the COM interface has not changed much, however. 我认为COM接口没有太大变化。

Here's how to add a COM/ActiveX dll to a LabView VI: 这是将COM / ActiveX dll添加到LabView VI的方法:

  1. Open a new VI 打开一个新的VI
  2. Go to the front panel 转到前面板
  3. Right-click, Refnum -> "Automation Refnum" (that's the buzzword you are looking for) 右键单击Refnum->“自动化Refnum”(这是您要查找的流行语)
  4. Right-click, Properties -> Select ActiveX Class 右键单击,属性->选择ActiveX类

If you can find your ActiveX function that way you are in good shape. 如果您可以通过这种方式找到ActiveX函数,那么您的状况就很好。 LabView property nodes and invoke nodes correspond to properties and methods. LabView属性节点和调用节点对应于属性和方法。

A web service is just an http call GET or POST, so that will always work. Web服务只是http调用GET或POST,因此它将始终有效。 However you will be on your own doing the parsing. 但是,您将自己进行解析。 (Also, LV 6.1 does not have http GET/POST built-in, so I used to use WinHTTP,via ActiveX as in the above, to perform those actions.) (此外,LV 6.1没有内置的http GET / POST,因此我以前通过ActiveX像上面一样使用WinHTTP来执行那些操作。)

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

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