LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

example in C# to use a Labview VI

Hi,

 

I have a VI written in labview 2011: I need to execute it from c# code

I do not have measurement studio installed

 

I can make a .net interop (best choice? or shared lib better?)

I can put it in the c# program and compile it

 

It crashes when run, gives exception to LV Runtime, cannot init

 

Anything special required in the c# program?

I am using VISA driver for the scope

 

A c# example or link to a helpful doc would be appreciated

 

Jeff

0 Kudos
Message 1 of 2
(3,697 Views)

Hey Jeff,

The best way to call your code from c# is a little bit a matter of personal preference.  I may be oversimplifying this a little bit but a DLL is a library that you will be able to use through any program running on windows where a .net assembly can only be run using the .NET framework.  DLL's are language dependent and have issues with backwards compatability where the .NET assemblies solved some of those problems.    A more detailed explanation can be found here: http://msdn.microsoft.com/en-us/library/6h38y9z9(v=VS.71).aspx  

 

The following article shows an example of creating a DLL in LabVIEW: https://decibel.ni.com/content/docs/DOC-15556

 

This help article gives good instructions for the .net Assembly: http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/building_a_net_assembly/  Some key things to note are that you need the LabVIEW Real Time Engine installed on the computer you are going to be calling the .net interop from.  The version of the .NET framework on the computer making the calls should be the same or later than the one LabVIEW used to create the .NET assembly.

To use both of these features in LabVIEW you will need to have the Application Builder Module which is an add on to the core LabVIEW product and can be found here: http://sine.ni.com/nips/cds/view/p/lang/en/nid/10731

 

If you have any issues with these steps or any additional questions please post back.

Kevin Fort
Principal Software Engineer
NI
0 Kudos
Message 2 of 2
(3,661 Views)