LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Control Labview Vi with C# (Runtime)

Hallo all,

 

Labview: 2013

Runtime :2013

 

my Problem: I want to control the Agilent 34401A with C# or C++ with the Labview Runtime. I tried to use ActiveX on c++. E.g crete Labview Instance -> GetViReference and so on. On my develop maschine it is no problem. But if i try to run my solution on the targit only with the runtime i cant create the Labview Instance.

 

Next try was to create a interop .net assembly. But if try to use the function of the .net assembly i get "Failed to call InitLVClient function".  I also add the NationalInstrument.Labview.Interop Assembly to my Vs2010.

 

I think i read all guides to this topic but i cant get a solution. Can anyone help me?

 

Regard moe

0 Kudos
Message 1 of 7
(3,512 Views)

Hello masterofeye

 

Please correct me if i got this wrong: You want to create an instance using the Runtime Engine.

 

"The runtime engine only contains functionality to run precompiled applications. It does not contain any compiler, application builder or even a possibility to save a VI."

from http://forums.ni.com/t5/LabVIEW/Why-does-Build-Application-vi-work-in-development-environment/td-p/2...

 

I hope this solves the question why creating an instance does not work.

 

Regards.

Veronika Kurz

National Instruments
Applications Engineering
www.ni.com/support
0 Kudos
Message 2 of 7
(3,411 Views)

@masterofeye wrote:

 

Labview: 2013

Runtime :2013

 

my Problem: I want to control the Agilent 34401A with C# or C++ with the Labview Runtime.


You have LabVIEW 2013. Do you have the "Application Builder"?

 

You can create a dll using the LabVIEW 2013 Application Builder on your development system and then call that dll using the LabVIEW 2013 Runtime engine from your C# or C++ on the other system.

 

You can control the 34401A stright from C. Why do you need to go through LabVIEW?

 

Omar
0 Kudos
Message 3 of 7
(3,404 Views)

Hallo and thx for the answers,

 

we need the labview solution because it was the idea of the designer.

 

I try to create all DLL and call it from C#. But it seems nothing is happend but the exit code is 0.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;



namespace ConsoleApplication6
{

    class Program
    {
           [DllImport("C:\\Program Files (x86)\\Agilent 34401\\SharedLib.dll")]
            public static extern Int32 Agilent34401_Initialize(char[] String);

        static void Main(string[] args)
        {
            char[] hallo = {'C','O','M','4'};
            Console.WriteLine(Agilent34401_Initialize(hallo));

        }
    }
}

 Is there anything to take care?

 

regard Moe

0 Kudos
Message 4 of 7
(3,333 Views)

What would you expect this function to do? It initializes the driver by trying to open the COM4 port and then it more or less ends. Not sure the Initialize functions does anything that would cause a visible change on the device. You should at least call another function after the Initialize that change some setting on the device so you can observe something happening.

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 7
(3,320 Views)

Hi Moe,

 

have you managed to find a solution to this problem??

I have exactly the same issue and i simply can't get a solution.

 

Regards Rui

0 Kudos
Message 6 of 7
(3,134 Views)

Dear All,

 

I found the solution to my problem and i'm just posting so that it may help someone with a similar issue:

My probelm was a dependency, basicly I had a IVI driver missing on the deployment PC, and unfortunatly the return error from the Labview Interop DLL was too generic  ("Failed to call InitLVClient function") for me to catch the problem imediatly. The strange part was that i wasn't using any call to the equipment on the Method i was calling.... 

So next time you get this error make sure you are not missing any dependency on the deployment machine.

 

Best Regards,

0 Kudos
Message 7 of 7
(3,123 Views)