|
-
May 15th, 2008, 05:20 PM
#1
Thread Starter
PowerPoster
true dll from VB6 problem
i am calling a true dll from vb6. the dll apparently has some problems. it starts screwing up and wont start working again till the computer is rebooted. It is always at different places and after different amounts of time. It happens on several computers.
I declare the offending function like this:
Code:
Private Declare Function n Lib "nnnn.dll" Alias "nnnn" (ByVal lng As Long) As lng_return
Public Function nnnn(ByVal lng As Long) As lng_return
nnnn = n(lp)
End Function
Is there anyway to destroy this function and redeclare it when this happens?
-
May 15th, 2008, 10:12 PM
#2
Re: true dll from VB6 problem
if the dll is in the process list you should be able to end the process
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
May 16th, 2008, 08:50 AM
#3
Thread Starter
PowerPoster
Re: true dll from VB6 problem
Thanks, but it isnt in the process list.
Just saw some different strange behavior ... after a while the app starts crashing on overflow errors at random places when making simple double variable assignments .... as simple as a=b (where a and b are doubles).
-
May 16th, 2008, 04:31 PM
#4
Re: true dll from VB6 problem
try to convert the doubles to longs as that is the datatype declared for the function
have you declared a type lng_return somewhere, the return of your function
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
May 16th, 2008, 10:35 PM
#5
Thread Starter
PowerPoster
Re: true dll from VB6 problem
 Originally Posted by westconn1
try to convert the doubles to longs as that is the datatype declared for the function
have you declared a type lng_return somewhere, the return of your function
actualy for the overflow problem all concerned variables are doubles .... strange ...
-
May 16th, 2008, 10:50 PM
#6
Re: true dll from VB6 problem
You're missing the point. The Function expects a Long variable type as an argument and will return a lng_return variable type. How is lng_return defined?
-
May 17th, 2008, 05:06 PM
#7
Thread Starter
PowerPoster
Re: true dll from VB6 problem
 Originally Posted by Doogle
You're missing the point. The Function expects a Long variable type as an argument and will return a lng_return variable type. How is lng_return defined?
thanks for the replies
the error is intermittent and almost never occurs at the exact same place in the code.
Public Enum lng_return
CRA= -2
CRB = 0
CRC = 1
End Enum
-
May 17th, 2008, 07:35 PM
#8
Re: true dll from VB6 problem
the error is intermittent and almost never occurs at the exact same place in the code.
how can the error occur at different points, if it is calling a dll function that is causing the error?
what is the code and values passed to the function
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
May 17th, 2008, 08:05 PM
#9
Thread Starter
PowerPoster
Re: true dll from VB6 problem
 Originally Posted by westconn1
how can the error occur at different points, if it is calling a dll function that is causing the error?
what is the code and values passed to the function
good question. my guess is a memory leak inside the dll.
fixing the dll isnt a short term option unfortunately (though that will get done eventually), so I am trying to find a short term workaround.
My hope is to find a way (without modifying the dll) to "restart" the dll somehow.
I discovered that I could put the true dll inside a com dll and call it from my app ... when the problems start, I destroy the com object and then recreate it. This works but the com interface is way too slow.
some more background info:
there are two different modes to operate the application. one uses the dll a lot (thousands of calls) and the other doesnt use it at all. the app runs perfectly in the latter mode. In the former mode (calling the dll) it gets unpredictable. there is nothing random in the dll design, yet sooner or later either the dll starts returning nonsense or I start getting overflow errors at code that works perfectly in the non dll mode. I just discovered that the app occasionally stops with "out of memory" error.
Last edited by Muddy; May 17th, 2008 at 08:09 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|