Discussion:
Class_Terminate problem & Run-time error'424': Object required
(too old to reply)
r***@gmail.com
2005-05-29 21:53:00 UTC
Permalink
Hi,

I have an Outlook addin written in VB6 that that is giving me an error
message box every time I close Outlook saying "Run-time error '424':
Object required.

It is code that I've inherited and have to fix, but I'm not sure what
is causing the problem. My investigation has led me to believe the
following might be causing it.

When the OnDisconnection event is called, two class variables of the
same type that were initialized at one point in the code are set to
Nothing. This invokes two calls to Class_Terminate. When
Class_Terminate is called for the first instance, it does the necessary
cleanup in the function and exits apporpriately. However when
Class_Terminate is called for the second variable, it never completes
it's cleanup because OnDisconnection reaches the end of the function
and exits the addin. And therefore I get the error message because the
objects are gone.

Does this seem plausible? Is there are way to ensure that the cleanup
routines can finish before the OnDisconnection exits (if this is the
problem)? Any suggestions?

Thanks.
Jan Hyde
2005-05-31 08:10:14 UTC
Permalink
Post by r***@gmail.com
Hi,
I have an Outlook addin written in VB6 that that is giving me an error
Object required.
It is code that I've inherited and have to fix, but I'm not sure what
is causing the problem. My investigation has led me to believe the
following might be causing it.
When the OnDisconnection event is called, two class variables of the
same type that were initialized at one point in the code are set to
Nothing. This invokes two calls to Class_Terminate. When
Class_Terminate is called for the first instance, it does the necessary
cleanup in the function and exits apporpriately. However when
Class_Terminate is called for the second variable, it never completes
it's cleanup because OnDisconnection reaches the end of the function
and exits the addin. And therefore I get the error message because the
objects are gone.
Does this seem plausible? Is there are way to ensure that the cleanup
routines can finish before the OnDisconnection exits (if this is the
problem)? Any suggestions?
Thanks.
It more likely that some code is trying to use that object
after the reference to that object has been set to nothing.

Why not just add some error code and then you'll know
exactly when it's happening.



Jan Hyde (VB MVP)
--
Universe: A one stanza poem (Stan Kegel)

[Abolish the TV Licence - http://www.tvlicensing.biz/]
Daniel Gard
2005-06-17 14:59:22 UTC
Permalink
rebkwez

What I do is check all objects in "OnDisconnect" to ensure they are nothing.
If your code does a call without checking the state of the object change it
so it does.

If not myObject is nothing then
set myObject = nothing
end if

If the object is nothing already the code is skipped.

DW Gard
Post by r***@gmail.com
Hi,
I have an Outlook addin written in VB6 that that is giving me an error
Object required.
It is code that I've inherited and have to fix, but I'm not sure what
is causing the problem. My investigation has led me to believe the
following might be causing it.
When the OnDisconnection event is called, two class variables of the
same type that were initialized at one point in the code are set to
Nothing. This invokes two calls to Class_Terminate. When
Class_Terminate is called for the first instance, it does the necessary
cleanup in the function and exits apporpriately. However when
Class_Terminate is called for the second variable, it never completes
it's cleanup because OnDisconnection reaches the end of the function
and exits the addin. And therefore I get the error message because the
objects are gone.
Does this seem plausible? Is there are way to ensure that the cleanup
routines can finish before the OnDisconnection exits (if this is the
problem)? Any suggestions?
Thanks.
Loading...