Click to See Complete Forum and Search --> : Problem unloading a COM DLL


smakadia
July 12th, 2001, 02:38 PM
I have a simple ATL/COM DLL that wraps a C DLL. A VB client access this DLL. Whenever I exit the client, I can't compile anymore. In the form_load() vb function I create an object of the component and then I release it in the exit function. But the DLL doesn't get unloaded from memory. Why?

Here is the VB code.

option Explicit
private withevents mEvent as MsgGrabber

private Sub Form_Load()
set mEvent = new MsgGrabber
End Sub

private Sub Form_Unload(Cancel as Integer)
set mEvent = nothing
End Sub

private Sub mEvent_MessageRetrieved(byval vString as Variant)
Dim var as Variant
var = mEvent.GetMessage
MsgBox var
End Sub

private Sub Send_Click()
mEvent.SendMessage ("Client string")
End Sub

smakadia
July 13th, 2001, 09:42 AM
Never mind! The VB code terminated abnormally so the DLL was never unloaded. MSDN says that VC++ 6.0 fixes this problem but it didn't in this situation. I just restarted VC++ and compiled and everything was fine after that.