I need to use cDynFactory frequently in my work. But now there are always some strange phenomena:
For example, MyTestForm uses cDynFactory to perform a series of operations:
(1) In VB6-IDE, after repeating "stop running (close MyTestForm) --- re-run (open MyTestForm)" several times,
the code "Set Obj = VBI.GetInstanceByUserDataOffs(UserData)" shows the following error prompt:
Automation eror
Invalid pointer
(2) So I added the following code to the Terminate event of MyTestForm:
After adding the above code, also in VB6-IDE, after repeating "stop running (close MyTestForm) --- re-run (open MyTestForm)" several times,
the code "VBI.NewInstance VBI.pVT(vtbl_IDispatch), Me, VarPtr( NewDynObj)" shows the following error prompt:
Run-time error '91':
Object variable or With block variable not set.
(3) When I close VB6-IDE, then re-open VB6-IDE, and click the run button (open MyTestForm), the above error message disappears. After repeating "stop running (close MyTestForm) --- re-run (open MyTestForm)" several times, the same error message appeared again. I don't know why.
For example, MyTestForm uses cDynFactory to perform a series of operations:
(1) In VB6-IDE, after repeating "stop running (close MyTestForm) --- re-run (open MyTestForm)" several times,
the code "Set Obj = VBI.GetInstanceByUserDataOffs(UserData)" shows the following error prompt:
Automation eror
Invalid pointer
(2) So I added the following code to the Terminate event of MyTestForm:
Code:
Private Form_Terminate()
If Forms.Count = 0 Then
New_c.CleanupRichClientDLL
End If
End Sub
the code "VBI.NewInstance VBI.pVT(vtbl_IDispatch), Me, VarPtr( NewDynObj)" shows the following error prompt:
Run-time error '91':
Object variable or With block variable not set.
(3) When I close VB6-IDE, then re-open VB6-IDE, and click the run button (open MyTestForm), the above error message disappears. After repeating "stop running (close MyTestForm) --- re-run (open MyTestForm)" several times, the same error message appeared again. I don't know why.