LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I import a Cvi DLL into Visual Studio.Net

It has taken a long time until I comeback to this question site. I received very much help from NI Engineers, and it became a great success to me in my new-frontier works.

In Labwindows/CVI, there is a very powerful multi-thread TCP/IP service functions, which enable the real-time monitoring of connection status. In the contrary, .Net does not have such a function. There is no easy way to catch the event of client disconnection just when the client finished its connection to TCP server.

So, I created a dll file of TCP/IP server tasks, and tried to use it in .NET circumstances. Doing this, I referred to the document of documentID=2TOIMGRT. Tlbimp.exe returned "??? is not a valid type library" when I tried to convert m
y CVI Dll library.

I think there may be two methods to fulfill my need.
One is in .NET side programming. Another is in CVI side coding.

In .NET programming, the method or algorithm of CVI would be very helpful if we know how the CVI catch the TCP/IP connection/disconnection event. I could not find any catching method of TCP disconnection event just when its event occurs.
In CVI programming, how should we make the dll file, which can be used in .NET.

I am still expect your powerful recommendation, as I have solved my problems through you of NI powerful engineers.

Thanks very much!
0 Kudos
Message 1 of 3
(3,702 Views)
Hello,

The Tlbimp.exe is utility created by Microsoft to convert COM objects to .NET assemblies. LabVIEW created DLLs are defined as COM objects by default, however CVI dlls are not COM objects unless you code yourself the COM interface in the dll.

The DLLs that CVI creates are just standard C dlls that can be called in most environments including VB or C#. Here is an article on-line that can help you call a dll in VB.

TCP programming in native .NET code is also possible, it is different that CVI but is you can get the same results; here is an example project that I found on the web for .NET tcp programming.

I hope this helps
, please post back any questions.

Regards,

Juan Carlos
N.I.
Message 2 of 3
(3,702 Views)
First My English is very but.....I´m sorry

There isn´t problem for use a CVI DLL in a project of Visual Studio NET.

I have a CVI DLL his name is "Dll_CromoElectra.dll" . This DLL have 2 Functions :

DLL_CROMO_AbrirPuertoCromoelectra(int iPuerto,int iVelocidad,int iParidad,int iBitsData,int iBitsStop
,int iLongBuf,int iLongBuf2,double iTimeOut);

int DLL_CROMO_CerrarPuertoCromoelectra(int iPuerto);


If you want use this DLL ( for Visual C# Project); you make this

#using System.Runtime.InteropServices;

/// Defined a Class to container de CVI FUNCTIONS
public class ClaseCromoElectraRs232
{
[DllImport("Dll_CromoElectra.dll", EntryPoint="DLL_CROMO_CerrarPuertoCromoelectra", CharSet=CharSet.Ansi,SetLastError=true)]

unsafe public s
tatic extern int CerrarPuertoCromoelectra(int iPuerto);

[DllImport("Dll_CromoElectra.dll", EntryPoint="DLL_CROMO_AbrirPuertoCromoelectra",CharSet=CharSet.Ansi,SetLastError=true)]
unsafe public static extern int AbrirPuertoCromoelectra(int iPuerto,int iVelocidad,int iParidad,int iBitsData,int iBitsStop,int iLongBuf,int iLongBuf2,double iTimeOut);

}


Your CVI DLL and Visual Studio Executable should be in the same directory , other options is put the CVI DLL in the System Directory.

If you have problem send mail to f.bermejo.garapen@adegi.es and a send to you a example complete of it.

Best regards

Tximis
Message 3 of 3
(3,702 Views)