ActiveX DLL and program hanging... 
Author Message
 ActiveX DLL and program hanging...

I've created an ActiveX DLL and am now having my EXE reference to it.  No
problems when running in the ide, once I compile and run from WIndows it
will hang when I exit my program.  The system won't hang, just the EXE which
is reported to be 'not responding'.

I can only assume it's the reference to the DLL, but what could be wrong?
Why would it hang like that?  Do I have to somehow de-reference the DLL from
the EXE when the EXE exits?

Jeff



Mon, 01 Jan 2001 03:00:00 GMT  
 ActiveX DLL and program hanging...
I had the same problem. Here is one avenue you may persue.
It worked for me.

As you know, the VB environment does garbage collection
of dynamic objects when the objects reference count
goes to 0 (ie nothing else is pointing to that object).

For ActiveX DLLs, they get unloaded when all public objects
they define have no references (either internal or external).

Things that can cause a DLL to stay loaded:
1) Global object defined in the dll
2) The dll itself has a reference to a public object inside the dll
3) Some code external to the DLL has a reference to a public object inside
the dll.

The VB documentation describes the situation (look up shutdown in books online
for VB5).

The way to fix it is to make sure there are no global objects (ie pass in
a dbConnection to the objects that need to access the database) and that
there are no references to global objects (use the class_terminate method
to clean up objects, setting all object references to nothing).

Hope this helps.
Arnold



Mon, 01 Jan 2001 03:00:00 GMT  
 ActiveX DLL and program hanging...
I had a similar problem because in a module I had a collection of all the
instances of an object in the DLL. The problem was that when the user
unloaded the object or set it to nothing it would not get unloaded since
there was still a reference to it in the collection.  I solved this by only
storing a pointer to the object in the collection instead of a reference.
ie:  MyCollection.Add ObjPtr(MyObject), ObjPtr(MyObject)
to get a reference back to the object from the object pointer you have to
use the CopyMemory API, (aka RtlMoveMemory and MemCopy)

' Declarations Section
Declare Sub MemCopy Lib "kernel32" Alias "RtlMoveMemory" (Dest As Any, Src
As Any, ByVal cb&)

Public Function GetObject(Ptr As Long) As MyObject
Dim TmpObj As MyObject
    MemCopy ByVal TmpObj, Ptr, 4
    Set GetObject = TmpObj
    MemCopy ByVal TmpObj, 0&, 4 ' Release Object
End Function

hope this helps


Quote:
>I had the same problem. Here is one avenue you may persue.
>It worked for me.

>As you know, the VB environment does garbage collection
>of dynamic objects when the objects reference count
>goes to 0 (ie nothing else is pointing to that object).

>For ActiveX DLLs, they get unloaded when all public objects
>they define have no references (either internal or external).

>Things that can cause a DLL to stay loaded:
>1) Global object defined in the dll
>2) The dll itself has a reference to a public object inside the dll
>3) Some code external to the DLL has a reference to a public object inside
>the dll.

>The VB documentation describes the situation (look up shutdown in books
online
>for VB5).

>The way to fix it is to make sure there are no global objects (ie pass in
>a dbConnection to the objects that need to access the database) and that
>there are no references to global objects (use the class_terminate method
>to clean up objects, setting all object references to nothing).

>Hope this helps.
>Arnold



Mon, 01 Jan 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ActiveX DLL causing application to hang.

2. activeX-dll hangs with 99% cpu-time

3. activeX-dll hangs with 99% cpu-time

4. ActiveX DLL Hangs IIS

5. Software Hang when called DLL hangs

6. Programs Structures for ActiveX DLL's

7. Get File List in a VB ActiveX Dll Program

8. add activeX dll in visuall c++ program

9. ActiveX DLL impact on program?

10. Get File List in an VB ActiveX Dll program

11. VB DB ActiveX DLL Program Structure Help...

12. Upgrade ActiveX DLL at program start?

 

 
Powered by phpBB® Forum Software