LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling LabVIEW from C# Using ActiveX?

Hi,

I try to call LabVIEW VI's from C# using ActiveX/COM, but I am not
successful. I was able to do this from C++ and there are nice articles on
the NI site dealing with the C++ integration.

I tried to follow the instructions of the C# help, using a wrapper for the
LabVIEW application call. I included the TypeLib that I created with the
tlbimp-tool in my project. Basically my code looks like this:

LabView50TypeLib._Application myLV = new
LabView50TypeLib.ApplicationClass() ;
LabView50TypeLib.VirtualInstrument myVI = new
LabView50TypeLib.VirtualInstrument();
myVI = myLV.GetVIReference(,?,?);
myVI.SetControlValue();
myValue= myVI.GetControlValue();
myLV.Quit();

I even don't know if the fi
rst line is correct. I know that the second line
is not OK, because there is no class "VirtualInstrument" - but from what
class should I derive my instance for the VirtualInstrument? And different
from my C++ implementation, the GetVIReference now needs 3 parameters
instead of 1 (the path).

What am I doing wrong? Does anybody have a working example on this?

Thanks a lot & best regards,
Martin Schellenberger
0 Kudos
Message 1 of 3
(3,659 Views)
Martin,

about the GetVIReference, it has 3 arguments:
VIPath: the VI path
Password: the VI password as a string, required only if the VI is password locked and you want to use properties/methods that modify the VI. Enter an empty string otherwise.
ResforCall: set to 1 when you want to invoke the "Call" method (the VI is put in the state "reserved for call" and can't be run or edited by user or other processes). Set to 0 otherwise.

About other issues, sorry I can't help you further.


LabVIEW, C'est LabVIEW

0 Kudos
Message 2 of 3
(3,659 Views)
Hello

After adding a reference to the LabVIEW type lib to the project (I just to o to Project >> Add Reference and I browse for the typelib myself), and including the labview namespace at the top,here is what I tried

using LabVIEW;
.
.
.
//form code here
.
.
.
//Event for button code
{
LabVIEW.Application lv = new LabVIEW.ApplicationClass();

LabVIEW.VirtualInstrument vi= lv.GetVIReference(@"c:\a.vi","",false);

vi.FPWinOpen=true;
vi.Run(true);

}

So all it does is it opens the VI and runs it, seems to work fine. Hope this helps

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 3 of 3
(3,659 Views)