07-02-2009 11:25 AM
I am using Labview 8.6 and VB.net 2008. I need to make a Labview DLL that will accept a 1D Array from Vb.net and return an Array of Calculations
I can make it work using integer values and strings, but Now i need to work with an Array.
I have done the following.
NOTE* the code on the bottom will just ask Labview to accept an Array from VB and return the Array Size.
Vb.net
Declare Auto Function Double2DMyTry Lib "SharedLib.dll" (ByVal MyArray() As Int32) As Double
Result.Text = CStr(Double2DMyTry(Numbers)) 'the code to call the function
labview function prototype
double Double2DMyTry(double Array[], double *Numeric)
using C calling convention
I get an error " attempted to read or write protected memory" when using the code above. I would in the end like to return back an array instead of just an integer.
Thanks.
07-02-2009 12:07 PM
07-02-2009 01:19 PM
OK. I have figured some things out that may help other newbies. First, you need to set your varibles as connectors as you would when making a SubVI. Now you will be able to see your variables when buliding the dll in the project explorer. 2nd, look at the Function Prototype in the build properties, it is asking for the Array following by the length of the array ( I was just sending the Array and this was generating my error above). Now I will try to figure out how to send back a 1D Array (I will post my solution once I get it, if there is no solution can someone please post it).
Thanks.
07-02-2009 01:50 PM
I think I am close now but keep getting a PInvoke Restriction Error
here is my Labview Function Prototype
void Double2DMyTry(double Array[], double Array2[], int32_t len, int32_t len2)
here is my VB CODE>
Public Class Form1
Declare Auto Function Double2DMyTry Lib "SharedLib.dll" (ByVal MyArray() As Int32, ByVal MyArray2() As Int32, ByVal Len As Int32, ByVal Len2 As Int32)
Private Sub btnPLus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPLus.ClickDim Numbers(4) As Integer
Numbers(0) = 1
Numbers(1) = 2
Numbers(2) = 3
Numbers(3) = 4
Dim FinalNumbers(4) As Integer
Double2DMyTry(Numbers, FinalNumbers, UBound(Numbers), UBound(FinalNumbers))
result.Text = FinalNumbers(0) + FinalNumbers(1) + FinalNumbers(2) + FinalNumbers(3)
End SubEnd Class
07-06-2009 03:36 PM
Hi Diopsys,
Does the following Discussion Forum help:
http://forums.ni.com/ni/board/message?board.id=170&requireLogin=False&thread.id=162333
Flash
07-06-2009 10:22 PM
07-07-2009 10:45 AM
07-07-2009 12:47 PM
Hi DiopsysP,
So you saw this:
http://zone.ni.com/devzone/cda/epd/p/id/4504
Why dont you want to use variants?
Flash
07-07-2009 02:04 PM
I have tried to make that example work for me for hours. I am using Labview 8.6 and VS 2008. I have recomplied everything again but I get " attempted to read or write protected memory" errors.
I dont mind using variants, anything that works.
07-08-2009 11:51 AM
Hi DiopsysP,
I just tried the example found on
http://zone.ni.com/devzone/cda/epd/p/id/4504
and it worked.
Have you tried it?
Flash