LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview dll .NET

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 .....   
0 Kudos
Message 1 of 7
(3,572 Views)


@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 .....   


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.

If you configure the DLL interface parameters accordingly in the application builder/project explorer, LabVIEW itself will take care to convert the parameters correctly between the outside C datatypes and the internally used LabVIEW datatypes.
 
Rolf Kalbermatter

Message Edited by rolfk on 02-08-2006 12:26 PM

Message Edited by rolfk on 02-08-2006 12:27 PM

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 7
(3,564 Views)

@ KaBooOoom

Have you already solved this Problem? I ask, because I now have the same problem.

Please reply

0 Kudos
Message 3 of 7
(3,426 Views)
Hi frankgriessbaum !
 
In order to solve this problem, i created a dll in C#. This Dll is an interface between VB. NET and Labview, so the aim of this dll is only to call labview functions provided by the labview dll. In C# you can use all basics types (Int32, IntPtr, string....).
 
But you have to be careful, because VB.NET use managed code and C# use non managed code. That means YOU have to allocate and free the memory in the C# Dll . Hmm ... that sound difficult, but you only have to use Marshal.AllocHGlobal and Marshal.FreeHGlobal ....
 
Now it works fine ,
0 Kudos
Message 4 of 7
(3,416 Views)
>In order to solve this problem, i created a dll in C#. This Dll is an interface between VB. NET and Labview, so the aim of this dll is only to call labview functions provided by the >labview dll. In C# you can use all basics types (Int32, IntPtr, string....).
>
>But you have to be careful, because VB.NET use managed code and C# use non managed code. That means YOU have to allocate and free the memory in the C# Dll . Hmm ... >that sound difficult, but you only have to use Marshal.AllocHGlobal and Marshal.FreeHGlobal ....
 
Thank you for posting!
But I have no idea, how I can create such a c# dll. What I have is a header-File from the LabVIEW dll. But I don't know how to use it.
 
I also have one more question: Which country are you from?
0 Kudos
Message 5 of 7
(3,410 Views)

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

 

 

0 Kudos
Message 6 of 7
(3,403 Views)

Thank you for replying so fast.

I'll try it...

0 Kudos
Message 7 of 7
(3,398 Views)