LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview - C#

Hello,
I just wanted to know whether calling a LabView DLL from C# code is possible or not.  I am trying to pass binary data from a C# program to LabView (in order for the latter to process and plot the data).
Thank you.
0 Kudos
Message 1 of 5
(4,398 Views)
It is possible, but you must remember that the DLL is unmanaged with a C interface. This means you'll need to define P/Inovke signatures for DLL methods. If you go to www.pinvoke.net, you'll find tons of examples on mapping P/Inovkes for Win32. A great place to get ideas for your own.
0 Kudos
Message 2 of 5
(4,372 Views)
Brian, thank you for replying.
 
I went to pinvoke.net and (unfortunately) got lost. Yes, I am a newbie Robot Sad.
I guess what I want to know is the difference between using Visual C++ and C# when it comes to calling a labview DLL.
My knowledge about using Visual C++ to call a labview DLL could be summarized using the following example:
Calling a LabVIEW-built DLL In C to Acquire, Analyze, and Present Data
http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=D6463414BBFF1646E034080020E74861&p_...
 
This  example is very simple (you don't pass or get data to the DLL ). However, I am assuming that if I need to call a labview dll in Visual C++, I should include the same *.h files (basically, I would have the same setup). Now, I don't think that I can use these *.h files in C# and expect them to work (though I have not tried).
 
What do you think?
0 Kudos
Message 3 of 5
(4,360 Views)
That is correct, you can NOT include .h files into C#. The languages (C# and C++) are much more different than the names imply. But, creating a P/Invoke isn't very hard, as long as you stay with simple data types. An example for calling a LV DLL with no parameters would be
 
[DllImport("mylabview.dll")]
static extern void MyLabVIEWFunction();
class MyClass
{
   public static void Main()
   {
      MyLabVIEWFunction();
   }
}
 
 
That's it.
0 Kudos
Message 4 of 5
(4,327 Views)
Ok. Thank you Brian Robot Happy I will give this a try and we will see what happens.
0 Kudos
Message 5 of 5
(4,322 Views)