Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing a DLL in C# (Sharp)

I need to find a way to generate a DLL in C#  which can be called by Labview. Our IT department writes its code in C#. They are to provide us with a company standard DLL so that we can read and write their database from our test stands. I understand that to interface with Labview, the DLL must provide calls in the "C" format. I'm not familiar with C#, but when I "google" the topic "C# DLL" they seem to be Class (C++) related rather than pure C format.

Has anyone had experience in creating a DLL in C# that can become a Labview VI? I would appreciate any comments on this.

(I have cross posted this to the Labview forum as this seems to span both categories).
0 Kudos
Message 1 of 2
(5,147 Views)
Hi DWendelboe,

You are getting confused between native Win32 DLLs and .NET assemblies and their usage.  If you were creating native Win32 DLLs (i.e. like from C++), then you would need to make sure that you exported the appropriate symbols in a C-style format. This is needed so that other environments can read that DLL.  In LabVIEW's case, you would be using the Call Library Function Node to call into this DLL. 

However, in your case your are using C# which means that the output of th C# compiler will be a .NET assembly.  In order to call .NET assemblies in LabVIEW, you need to use the .NET functions and VIs such as the .NET Constructor Node (i.e. which creates a instance of a class --> an object that you can use).  You can read more about this in the Using .NET with LabVIEW help topic which explains in detail how to use .NET assemblies with LabVIEW.  I would also recommend checking out the .NET shipping examples that are installd with LabVIEW. 
To access those examples, just open up the NI Example Finder (Help >> Find Examples) and then navigate to the Communicating with External Applications >> .NET directory.

Hope this helps!

Best Regards,
Jonathan N.
National Instruments
0 Kudos
Message 2 of 2
(5,134 Views)