04-02-2012 08:10 AM - edited 04-02-2012 08:11 AM
Hi everyone,
I am working on a project (actually a proof of concept) where I need to call and use LabVIEW VI's in a C# application.
I downloaded the example available on this page : Calling LabVIEW VIs from Other Programming Languages.
This example (joined) is working fine, but I would like to know if there is an associated documentation concerning the .NET classes that I can use in C# when I use the namespace "LabVIEW" (using LabVIEW; in C#).
I need to know a little more about the properties and methods that are available (what it does and how to use it).
I looked for it on NI's website and the LabVIEW help but could not manage to find anything interesting.
Is there an official documentation released ? How can I get those informations ?
Thanks for your answer(s).
Regards,
04-02-2012 09:19 AM
That specific example is calling LabVIEW from C# using ActiveX. Is this what you are specifically trying to do, or are you intending to create a .NET Interop Assembly from the LabVIEW code? Those are two fundamentally different approaches.
04-02-2012 09:57 AM
Hi smercurio_fc,
I want to call LabVIEW using ActiveX in C#, this is what the example is doing.
But I couldn't find any informations about the methods and properties available from the ActiveX (if I want to use the other methods available and not only the one included in this example).
Do you have any idea where I can get those informations ?
Regards,
04-02-2012 10:07 AM
You must not have used LabVIEW very much. Simplest is to select VIEW>Class Browser.
04-02-2012 10:48 AM
Hi,
The class browser is usefull (ctrl + shift + b), but I am not developing the C# application on the same computer than the LabVIEW application.
The *.chm file has all the informations in it but I am not finding it well organized. I am drowning in all the informations. I supposed there was a specific help file / manual for the ActiveX methods and properties (a kind of hierarchical view like in the class browser).
Also I supposed that there were different methods and properties that the one available in LabVIEW.
For example when I browse the class in C# I get those weird methods :
Regards,
04-02-2012 11:52 AM
The properties and methods are all documented in the LabVIEW Help. Fundamentals -> Windows Connectivity -> How-To -> ActiveX -> Properties and Methods. For the labviewApp variable in your example you'd be looking at the "Application" subchapter. Any of the methods/properties that start with "_" are undocumented and should not be used.
01-07-2022 02:42 AM
Hello Team ,
My requirement is to control VI from C# application and i got the link to https://download.ni.com/pub/gdc/tut/callinglvcsharpusingactivex.zip.
The dll available in this project is Assembly Interop.LabVIEW which is serving my purpose but as several seeker asked before what is the systematic way of learning and achieving knowledge to control VI panel from a C# project?
Where can i get complete information on the Assembly Interop.LabVIEW ?
Thanks in advance for your time and knowledge!
Thanks and Regards,
Chetan
01-07-2022 03:51 AM - edited 01-07-2022 03:59 AM
National.Instruments.LabVIEW.Interop.dll as the name already says is an Interop assembly. It uses some Windows API calls and many private LabVIEW APIs to do its things for various .Net tools that NI distributes but it is not really meant for customer use and hence not officially documented.
This means you can try to use it but there is no guarantee that what you found out will exist in a newer LabVIEW version, or work in the same way, or not have suddenly a bug since it is a method that NI doesn't use anymore and therefore doesn't test.
The only officially supported ways to call LabVIEW methods from a .Net application are:
- Through the LabVIEW ActiveX Automation interface
- Creating a .Net assembly in LabVIEW from your code and calling it from your application
The example provided in your link uses the first method by referencing the LabVIEW Active X Type Library. Visual Studio then helpfully creates an interop library for you to translate between your .Net application and the ActiveX interface for LabVIEW. The documentation of this ActiveX interface is in the LabVIEW online help under Contents->Property and Method Reference->ActiveX.
As already mentioned this is a rather small subset of the actual LabVIEW VI Server interface but that is all that you can use without going into creating your own C# Interop vodoo by hand to directly call into LabVIEW kernel exported functionality.
01-10-2022 12:25 PM
Thanks a lot for such a nice description ,this information helped me a lot!
I went through the Information available in the help documents on "ActiveX" ,I studied methods, properties ,enums ,object names etc. available for the user to access kernel exported features but i failed to figure out the file path or name of library/dll to be linked before I start writing my own C# interop to access LabVIEW kernel . Could you please share some knowledge on file information to directly call into LabVIEW kernel exported functionality.
Would C:\program files (x86)\national instruments\shared\labview run-ime\XXXX\NationalInstruments.LabVIEW.Interop.dll be the right dll to be used to access functionality and methods mentioned in help document ?
Thanks again for your support!
Thanks and Regards,
Chetan
01-11-2022 04:50 AM - edited 01-11-2022 04:57 AM
@ChetanRao wrote:
C:\program files (x86)\national instruments\shared\labview run-ime\XXXX\NationalInstruments.LabVIEW.Interop.dll
No that is not the right thing. That is the library I mentioned in the beginning. It is private and undocumented.
The project in the example specifies the LabVIEW Active X interface by its GUID {9A872073-0A06-11D1-90B7-00A024CE2744} which tells Visual Studio to look in the registry for the actual interface definition. When you look that up in the registry you will see a reference to a LabVIEW Type Library.
It's path is registered to be C:\Program Files (x86)\National Instruments\LabVIEW <version>\resource\labview.tlb
This Type Library is a resource that describes the ActiveX interface and where to find its server (usually the LabVIEW.exe file).
This server is then instantiated through Microsoft COM, the technology on which ActiveX is built. Visual Studio automatically generates an Interop assembly resource to translate between a .Net interface that you can directly call from your C# code and the ActiveX Automation Server interface that LabVIEW provides and which also takes care about instantiating the necessary ActiveX Automation Server.
You should be able to add a reference to an ActiveX Automation Server in your Visual Studio project without the need to specify a GUID or a direct path to some Type Library by somewhere adding a project reference that lets you browse all currently registered ActiveX Automation Servers on your system by their name. Although there is the possibility that recent Visual Studio versions have made that less than trivial to do. Microsoft actively tries to get away from ActiveX and discourages its use as much as possible, to eventually remove it as a supported technology sometimes in the not so near future.