02-08-2006 04:30 AM
02-08-2006 05:24 AM - edited 02-08-2006 05:24 AM
You can't use the native LabVIEW datatypes to create a DLL if you want to call this DLL from anything but LabVIEW. Instead you have to use the standard C types. So for LStrHandle you use char* which is equivalent to LPSTR, LVBoolean is a long or BOOL, etc. While for simple skalar types it is just about naming them and .Net not having any idea about LabVIEW datatype naming conventions, for strings and arrays .Net is not able to deal with the native datatype layout at all that LabVIEW is using.
@KaBooOoom wrote:Hi !I need some help !I have the following problem: I created a Labview dll. Now i want to call this labview from VB .NET ! But .NET doesn't recognize labview types such as LstrHandle, LVBoolean, ErrorCluster, Array, and so on... I searched on the web, and i think i have to create a C library in order to convert Labview types into C and C types into labview ! I found different exemples in the forum in order to convert a labview string (LstrHandle) into C, and ... i din't manage to compile and launch the exemple....My question is the following : Does anybody knows if a C library exist in order to convert the different types ??? I guess i'm not the first person who faces this problem... I hope labview enginners developped such a library ....! Or is there another better solution ???Thanks a lot for your replies .....
Message Edited by rolfk on 02-08-2006 12:26 PM
Message Edited by rolfk on 02-08-2006 12:27 PM
09-21-2006 12:30 AM
@ KaBooOoom
Have you already solved this Problem? I ask, because I now have the same problem.
Please reply
09-21-2006 04:48 AM
09-21-2006 06:34 AM
09-21-2006 07:08 AM
Hi !
In this header file , you have the prototype of the functions declared in your dll. Well, in C#, you create a class e.g. LabViewInterface. Then you define all fucntions uses in your labview dll. In VB. NET, you will use the C# dll instead of the labview dll.
For example :
public class LabviewInterface
{
[DllImport("LabViewDll.dll")]
private static extern void Function1(string param1, IntPtr param2, Int32 param3);
public static void mFunction1 (string param1, out string param2) {
IntPtr ptrError = Marshal.AllocHGlobal(STRLENGTH);
Function1(param1,ptrError,STRLENGTH);
param2= Marshal.PtrToStringAnsi(ptrError);
Marshal.FreeHGlobal(ptrError);
}
From VB.NET, you will call LabviewInterface.Function1.
And for your second question... I'm french
09-21-2006 07:21 AM
Thank you for replying so fast.
I'll try it...