LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.NET component in Labview

I've got Labview 8.5.1 and some VB code that was written by someone else.  The VB code takes a 2d array and does some data mining and statistical analysis and spits out about 10 real numbers that represent the analysis of the data.  My plan is to take this VB code and somehow stuff it into a Labview VI.  The Labview VI generates the 2d array (about 15000 data points, BTW).  I've got Visual Studio 2005, so I took the VB code and made it into a .dll using Visual Basic.  I can call this .dll from another VB.NET program, and it works fine.  I tried putting a "Call Library Node", but it couln't find the functions available in the .dll.  A little research indicated that I can't create the correct type of .dll with VB.NET.  So, what are my options here?  Can I create a .NET component to drop into Labview?  If so, are there any tutorials or examples out there?  TIA!
0 Kudos
Message 1 of 16
(4,542 Views)
With VB.NET you get a file with a .dll extension, but it's actually a .NET assembly. To use it in LabVIEW you would need to use the .NET functions. There are a number of examples that ship with LabVIEW that show you how to call .NET assemblies. Open the Example Finder (Help -> Find Examples) and search for .NET.
0 Kudos
Message 2 of 16
(4,521 Views)
Thanks, I've found an example that calls the calculator via .NET.  I re-did my VB project as a .NET .dll, so I think it will work.  The problem I'm running into now is that the method I'm trying to invoke has three parameters, two 1d arrays of type string, and a double.  I've got the arrays in my VI, but when I connect them to the invoke node, it says the data type is mismatched.  It says that the parameters of the invoke node are ".NET refnum".  Any idea what that means, and how I can fix it?
0 Kudos
Message 3 of 16
(4,518 Views)
You're probably using an ArrayList or some other .NET class for the arrays. If you post the .NET assembly as well as the prototype for the method I can verify this.
0 Kudos
Message 4 of 16
(4,516 Views)
Here's the prototype for the method:

Public Sub ProcessData(ByVal Displacement As String(), ByVal Force As String(), ByRef Displacement1 As Double)

By "assembly", do you mean the compiled .dll?

0 Kudos
Message 5 of 16
(4,514 Views)
Yup. You'll need to ZIP it, though, since you can't upload .dll files.


Message Edited by smercurio_fc on 06-26-2008 09:54 AM
0 Kudos
Message 6 of 16
(4,512 Views)
The attached zip file contains the dll.  The constructor is "myTester", and the method is "ProcessData"  You pass it two arrays of strings that contain numbers (represented as strings), and it finds the largest of the first array.  It's kind of a stupid example, but it should work.
0 Kudos
Message 7 of 16
(4,506 Views)
Well, I was able to wire it up just fine. However, when I ran it I got an exception "System.IndexOutOfRangeException: Index was outside the bounds of the array." Do the arrays need to be of a specific size?




Message Edited by smercurio_fc on 06-26-2008 10:36 AM
Download All
0 Kudos
Message 8 of 16
(4,497 Views)
smercurio_fc -

I think I've got it working now.  I downloaded your VI and it worked.  So I went back and re-created my VI and it worked.  I had made some changes to my dll, but my VI was still using the old version of the dll.  It seems that if I make a change to my .dll, I have to re-create the VI for it to reload the dll.  Is there an easier way to reload the dll?  Thanks again.

Oh, by the way, the method is expecting static arrays with 33000 items.  Like I said, it's a dumb example Smiley Wink


Message Edited by ccote on 06-26-2008 11:21 AM
0 Kudos
Message 9 of 16
(4,485 Views)
As I had noted in another recent post on LabVIEW and .NET, the LabVIEW <-> .NET interface is not the most robust in the world. It has improved considerably over the LabVIEW versions. It also depends on whether you're dealing with a private assembly that's in a specific folder, or a strongly named assembly that's in the GAC.

I'm currently using 8.2, and version changes to assemblies are a sometimes real pain. I've never had to recreate a VI entirely, but sometimes I've had to delete the .NET controls/indicators and place new ones, or delete the constructor only and place a new one. Even them I've sometimes had to go and reselect the methods and/or properties.

I don't know how you have your code setup, but you may find the the following of some help:

How LabVIEW Locates .NET Assemblies



0 Kudos
Message 10 of 16
(4,461 Views)