LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Labview functions in C#

Solved!
Go to solution

Hello everyone.

I only found a lot of misleading or incorrect tuto on the topic.
I would like to know the exact procedure to use a VI I created in Labview in C#.
Actually I commincate with a Keithley 2700 via Labview but I would like to do it in C# using the VI's I created in Labview. But I don't know how to it.
Can someone show me with a basic example how to export a simple function like dividing a number ?
Thanks a lot.
Btw I'm working with Labview 2019 and C# .net 4.7 in Visual Studio

Have a nice day.
Labview.PNGcsharp.PNG

0 Kudos
Message 1 of 9
(4,193 Views)

You don't know how to write a simple function in C#  to perform division such that you need to export a VI to C# to do it?

Is that what you are saying?

 

You don't want to take the time to learn how to program in C# ?

0 Kudos
Message 2 of 9
(4,137 Views)

Absolutely not, i want to know the method to create Dll from labview and use it in C# and I'm asking if someone could explain it to me with a simple function like dividing 2 numbers. It is just an example that will permit me to do more complicated functions in the future.

0 Kudos
Message 3 of 9
(4,129 Views)

Creating a DLL in LabVIEW to call in C# is not what your subject line says.

 

Now that we know that, I suggest Google search on the correct subject, and you will find examples.

0 Kudos
Message 4 of 9
(4,126 Views)

I assume you have the LabVIEW application builder. (included in LabVIEW professional, or available here)

 

Start reading here.

 

(I also noticed that you use 64bit LabVIEW, so make sure to account for that.)

0 Kudos
Message 5 of 9
(4,096 Views)

While you still wll need the Application Builder you rather want to create a .Net Interop assembly instead of a Shared Library (DLL) for use from a C# application.

The limitations are the same, the resulting DLL or shared library will only be useable from a C# application with the same bitness as what the LabVIEW version has that is used to create it. In both cases the VI code is compiled into the according CPU assembly code and a wrapper is created to call it from the respective environment. For the .Net Interop Assembly a .Net Interop wrapper is created that allows to call the function directly from your C3 code. If you create a shared library instead, you have to generate your own Interop interface definition in C# to call it.

Rolf Kalbermatter
My Blog
Message 6 of 9
(4,059 Views)

ks for you answer, so if I understand correctly...
I have to create a .Net Interop assembly from the function I want in Labview, give it a class name.
Make a reference for that assembly in C#, then create a class that will have the same name ? And then I can call the functions inside ?

0 Kudos
Message 7 of 9
(4,010 Views)
Solution
Accepted by topic author Kamigo

You should not need to create a class with the same name in C#. The Interop assembly already is the class implementation. Once you have added a reference to the assembly to your project it should be usable in any module where you add an according use clause.

Rolf Kalbermatter
My Blog
Message 8 of 9
(3,992 Views)

Ok thanks for your answer I did it.
My initial problem was that we don't find enough syntax example on the internet so I didn't know how to do it in practice.

0 Kudos
Message 9 of 9
(3,746 Views)