Results 1 to 9 of 9

Thread: true dll from VB6 problem

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046

    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?

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046

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

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046

    Re: true dll from VB6 problem

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

  6. #6
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    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?

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046

    Re: true dll from VB6 problem

    Quote 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

  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046

    Re: true dll from VB6 problem

    Quote 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
  •  



Click Here to Expand Forum to Full Width