Can call dll from VB6, can't from VB.Net

Jamie

New member
Joined
Mar 23, 2004
Messages
3
Hello, Ive got a problem...

When I use the following LIB call in VB6 it works fine...

******
Declare Function vxcomm_vb Lib "vxcomm.dll" (ByVal owner As Short, ByVal cmd As String, ByVal sys As String, ByVal app As String, ByVal crfs As String, ByVal port As Integer, ByVal config As Integer) As Integer
******

"Working fine" under VB6 means that the dll referenced above is called, and it does some work with a device on a com port, and it has its own GUI to show the progress of the connection to the device.

Im trying to move to .Net, so when I upgraded the project, the upgrade completed without error. The problem is, when I run the .Net upgraded version of the app, the dll is called successfully, but only for a split second. I can see the GUI of the dll on the screen for a millisecond, then it disappears. Further, the dll is designed to return an integer as you can see, at it does so, even though killed prematurely.

How do I get .Net to wait for the dll to finish its work?
 
I am not sure how you included it into your vb.net application.
But is is quite simple compare to VB.

while the project is opened,
on your solution explorer, right click on references, then choose Add References.
Choose the dll file and click OK.

im your code-base, do Imports library_name on the top of your application. .Eg: Imports SpeechLib

Thats are the steps needed. Once complete, the functions in the library are avaible in your application.
 
georgepatotk said:
I am not sure how you included it into your vb.net application.
But is is quite simple compare to VB.

while the project is opened,
on your solution explorer, right click on references, then choose Add References.
Choose the dll file and click OK.

im your code-base, do Imports library_name on the top of your application. .Eg: Imports SpeechLib

Thats are the steps needed. Once complete, the functions in the library are avaible in your application.

Thanks George, but that was one of the first things I tried. Actually, this method of adding reference to a file is supported in VB6 also. Unfortunately, adding a reference to the file doesnt work in either VB6 or VB.Net as the dll file is "not a valid COM component". It does work if referenced in code as a "Lib" however, as I think the dll was written in C, and "Lib" lets you call to non-COM code.

The function actually does work in VB.Net, it just doesnt get enough time to run. I think this is because of tighter threading restrictions but Im guessing. My question is, how do I hand off to the DLL, or at least let it run in a seperate thread? VB6 allows the DLL to function similar to a MsgBox, it appears to hand off execution until the DLL is finished, then continues on from there, which would be ideal.
 
Problem fixed...

It turns out the way I was referencing the dll was fine. After talking to the manufacturer I found out I was passing an incorrect variable.

Thanks!!!
 
Back
Top