From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Run a LabVIEW VI from VB without compiling

I've got a couple of LabVIEW VI's that I want to run from VB without having to compile them.  I can run them fine on the development machine using:
    CreateObject("LabVIEW.Application")

When I try this command on another machine that has the LV Runtime Engine installed it returns a run-time error "429: ActiveX component can't create component"

I've read a few posts with similar problems however they don't seem to provide any real solutions.
All tips/help are greatly welcome.

Woody
0 Kudos
Message 1 of 11
(3,686 Views)
You have to create the application with the application builder and setting "Enable ActiveX Server" in the Advanced page. There you can enter the name of the server, e. g. MyApp.
 
In VB you need to use CreateObject("MyApp.Application") to connect to the server.
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 2 of 11
(3,673 Views)
Thanks Waldemar,

I can do it by compiling a DLL or EXE, however I can run on my development machine the VI's in .vi format without having to compile them.  Surely this should be possible to be done away from the development machine.

I know you can run .vi files using the LabVIEWControl (ActiveX) using web pages which is contained in the LabVIEW runtime engine.  I've tried using that control but can't seem to find a list of properties to use these from Visual Basic.

The reason I want to be able to run the .vi's is so I don't have to recompile the .vi's into .dll's every time I make an amendment to the code.  The .vi's are used on a few machines which would mean re-registering the .dll's which is not very feasible.
0 Kudos
Message 3 of 11
(3,669 Views)
You just need to create a small app which register once and then load the VIs dynamically or over the command line. This way you just need to replace the VIs in the case you make any changes to them without need to reregister the app again.
 
http://forums.ni.com/ni/board/message?board.id=170&message.id=228902 is a discussion about how to run VIs without creating an app again and again. Do not mind about Linux the thread is going also to Windows. Read all the three pages.
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
Message 4 of 11
(3,664 Views)
Hey Waldemar,

That's all very interesting stuff, however I'm looking to get back information from the VI's without outputting the return information in to a file as that's messy and inefficient.

I'm currently looking into ways of using the references that VB uses on the development machine to run native VI's.

All the best
Woody
0 Kudos
Message 5 of 11
(3,631 Views)

Hey Woody,

this is an extract from a example of a VB app using LV VIs.

    'Create a reference to LabVIEW
    Set lvApp = CreateObject("ETLKWP.Application")

    'Assign an object reference to VI
    Set VI_open = lvApp.GetVIReference("ETLKWPOpenCommunication.vi")
    Set VI_close = lvApp.GetVIReference("ETLKWPCloseCommunication.vi")
    Set VI_DeviceType = lvApp.GetVIReference("ETLKWPDeviceType.vi")

This code will load the application, here ETLKWP, and three VIs. These VIs will be found by the app on the VI search path. Since one part of the search path is "all subfolders" you can place them in any subfolder of the folder where your app is.

Private Sub DeviceType_Click()
  Dim ParamNames(0 To 😎 As String
  Dim ParamVals(0 To 😎 As Variant


   ParamNames(0) = "PrimTarget"
   ParamNames(1) = "PrimIndex"
   ParamNames(2) = "Source"
   ParamNames(3) = "DeviceType"
   ParamNames(4) = "DeviceIndex"
   ParamNames(5) = "Syyy"
   ParamNames(6) = "Hyyy"
   ParamNames(7) = "SerialID"
   ParamNames(8) = "ErrorNumber"

   ParamVals(0) = PrimTarget
   ParamVals(1) = PrimIndex
   ParamVals(2) = 0
   ParamVals(3) = 81
   ParamVals(4) = 1

   Call VI_DeviceType.Call(ParamNames, ParamVals)
   SW_Stand = ParamVals(5)
   HW_Stand = ParamVals(6)
   Serienid = ParamVals(7)


End Sub

This part of code will call the VI DeviceType.vi. The parameters 0 - 4 are controls and 5 - 8 are indicators which are connected with the connector pane. This VI will send a message over a serial connection to an external device and the device will answer with its firmware, hardware and serial information. This information is now available in the VB program.

Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 6 of 11
(3,630 Views)
I'm assuming you're compiling a .dll named: "ETLKWP" in LabVIEW as the LabVIEW Application and adding as a Reference?

I'll try that.
0 Kudos
Message 7 of 11
(3,613 Views)
ETLKWP is an exe with ActiveX server enabled.
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 8 of 11
(3,607 Views)
VB's definitely not finding the .exe and letting me use it as a reference.

I've compiled a blank VI with the ActiveX Server checked and placed it in the directory where the VB app is running from.  Using the code above, it returns:
    "Run-time error '429':
        ActiveX component can't create object."

Tried adding the .exe as a reference in VB too but it didn't like that either.  I'm using VB6 if that's any help?

Thanks Woody
0 Kudos
Message 9 of 11
(3,582 Views)

Each ActiveX Server must enter some information in the registry. After that it can be found by the ActiveX client programs. LabVIEW has the advantage to do it on its own.

Start the program with adminstrator rights one time. It will register itself. From then on it will be found by the VB app.

Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 10 of 11
(3,579 Views)