Example Code

Running or Calling a VI using the LabVIEW ActiveX Automation Server from C# .NET

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Download All

Overview

This is an example that shows how to run a VI created in LabVIEW from an external program using the LabVIEW ActiveX Automation Server.

 

Description

Sometimes calling a created VI in LabVIEW will make our programming process much easier. Here is an example that demonstrates how to run or call a VI in LabVIEW via LabVIEW ActiveX Automation Server.

 

Requirements

  • LabVIEW 2012(or compatible)

  • LabVIEW ActiveX Automation Server

    (This can be enabled by checking the ActiveX box on the VI Server page of the LabVIEW Tools>Options dialogue.)

  • Visual Studio 2012

  • Make sure to extract the ZIP to C:\RunlabVIEW or modify the viadd_path variable to match the VI’s location on your machine.

 

Steps to Implement or Execute Code

  1. Make sure the LabVIEW ActiveX Automation Server can be used and extract the ZIP to correct directory.
  2. Using Visual Studio and ActiveX Automation Server to run this Add.vi in LabView to fufill the function of Adding numbers.

Additional Information or References

 

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Justin D
Applications Engineer
National Instruments
http://www.ni.com/support/

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
jigneshmehta
Member
Member
on

Hello ,

I have a similar Use case.But i am unable to locate Interop.LabVIEW.dll 

What i found was NationalInstruments.LabVIEW.Interop.dll but it does not have the methods/Classes that i can use as in your example

FYI..I am trying in NationalView 2014 runtime

Jomps
Member
Member
on

Hi,

 

The GetVIReference function always generates an exception fault when either of the example projects are run. Have copied the exception fault details below this email.

 

My setup is LabVIEW 2016 V16 64-bit and Visual Studio 2017. I run the project with administrator permissions.

 

The Interop.LabVIEW COM component description is 'LabVIEW 8.0 Type Library' and the version is '5.5.0.0'.

 

Tried 32-bit and 64-bit configurations. Also tried versions 4 and above of the .NET framework.

 

Have searched the internet answers but have not found anything useful yet.

 

Can anyone help with this?

 

Kind regards,

 

 

Jon

 

System.InvalidCastException
  HResult=0x80004002
  Message=Return argument has an invalid type.
  Source=mscorlib
  StackTrace:
   at System.Runtime.Remoting.Proxies.RealProxy.ValidateReturnArg(Object arg, Type paramType)
   at System.Runtime.Remoting.Proxies.RealProxy.PropagateOutParameters(IMessage msg, Object[] outArgs, Object returnValue)
   at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
   at LabVIEW._Application.GetVIReference(String viPath, String password, Boolean resvForCall, Int32 options)
   at RunLabVIEWVI.Program.Main(String[] args) in C:\Projects\RunLabVIEWVI 2012 NIVerified\RunLabVIEWVI\Program.cs:line 25