01-03-2020 07:32 AM
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.
Solved! Go to Solution.
01-03-2020 10:04 AM - edited 01-03-2020 10:04 AM
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# ?
01-03-2020 10:09 AM
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.
01-03-2020 10:15 AM
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.
01-03-2020 01:06 PM - edited 01-03-2020 01:08 PM
I assume you have the LabVIEW application builder. (included in LabVIEW professional, or available here)
(I also noticed that you use 64bit LabVIEW, so make sure to account for that.)
01-03-2020 04:59 PM - edited 01-03-2020 05:00 PM
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.
01-04-2020 04:02 AM
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 ?
01-04-2020 07:07 AM - edited 01-04-2020 07:08 AM
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.
01-06-2020 01:09 AM
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.