LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I build a VB.Net Compatible DLL in CVI 2010?

I have some old DLL files that I built using CVI 6.0 (or thereabouts) that were VB6 compatible.  I built them by changing the calling convention from _cdecl to _stdcall, and exporting the header files containing all DLL constants and functions to VB Compatible BAS files.  We haven't used these libraries in a long time and now we have a customer who wants VB.Net compatible dll files of the same project.  I was wondering how to go about building them in CVI 2010.  Is it the same process?

 

Thanks ahead of time for any help.

 

Judy

0 Kudos
Message 1 of 3
(3,232 Views)

Hi Judyh,

 

I found an article on creating a CVI DLL for Visual Basic. It is listed below for your reference.

 

http://digital.ni.com/public.nsf/allkb/2B42270EAC4A109C862569AE006253C1?OpenDocument

 

It looks like the procedure is still the same. 

 

I hope this helps.

 

Josh L.

Applications Engineer
National Instruments
0 Kudos
Message 2 of 3
(3,219 Views)

That doesn't mention VB.NET it doesn't look like to me, though from the CVI created DLL side things may be the same as with VB6.

 

You can invoke a traditional, non-ActiveX DLL created in CVI from a .NET language by using P/Invoke (Platform Invocation Services).

 

Here's an example adapted from C# 4.0 In A Nutshell from O Reilly.  VB.NET is similar.

 

using system;

using System.Runtime.InteropServices;

 

class Test {

  [DLLImport("myCVIDLL.dll")]

  static extern int myCVIdllFunction (int myParam);

 

  public static void Main() {

        int iReturn = myCVIdllFunction (1);

  }

 

}

 

 

To build the CVI DLL, I'd suggest following the same calling convention as you did for the VB6 compatible one. 

 

I've always used

 

INT DLLEXPORT DLLSTDCALL myCVIdllFunction (int i) { ... }

 

for a DLL function signature that I wanted to be available from VB6.  I usually include a type library resource too, I don't know if .NET will use one or not.  It should be harmless enough to include one and see what happens.

 

0 Kudos
Message 3 of 3
(3,215 Views)