ApptItem_open

J

Jack

I have an add-in application that responds to the _open event of an ApptItem
(decl and sub below).

If I do anything that sets cancel to true the add-in does not completely
release memory. If I debug, fire the event then remove the add-in via
com-addins and then stop debugging it tells me that the program is still in
use. Yet, if is allow the appt to open then close it things are relased and
the program ends without a problem.

Is there something else I should be doing?


Appt Item declared:
Private WithEvents objApptItem As Outlook.AppointmentItem

Private Sub objApptItem_Open(Cancel As Boolean)
cancel=true
End Sub
 
K

Ken Slovak - [MVP - Outlook]

Are you releasing all of your related Outlook objects?

If this is managed code then just setting them to Nothing may not be enough.
You might also have to call Marshal.ReleaseComObject() until the return
value is 0 and there are no more references to that RCW, then you'd call
GC.Collect().

You can tell what's left around by looking at your locals at the time the
class is going out of scope to see exactly what references are still in use.
 
J

Jack

Ken,

This is in VB6 so do not have access to the Marshal.ReleaseComObject() or
garbage collection classes.

Even if I step through this code (see below for the _open event code) and
chek the value of objApptItem after setting it to nothing as well as set it
to nothing in the uninithandler it still refuses to clear memory. However
if I do nothing in the objApptItem_open event and let the form open it
releases just fine.

Private Sub objApptItem_Open(Cancel As Boolean)
objApptItem.Close olDiscard
Set objApptItem = Nothing
Exit Sub
end sub
 
K

Ken Slovak - [MVP - Outlook]

Version of Outlook?

Does the objApptIem object get used or referenced anywhere else in your
code? Are you handling any other events for that object?
 
J

Jack

Development is Outlook 2000 (so we can deploy in 2000-2007), which is where
I am seeing this behavior.

No the object is not used or referenced elsewhere. It is created in a
NewInspector event and then set to nothing in the UnInitHandler.

Could it be a 2000 bug?
 
K

Ken Slovak - [MVP - Outlook]

I've never run into that as a bug, although I really haven't used Cancel on
the Open() event very often. If this was managed code I'd say it could be a
bug since the PIA for Outlook 2002 is buggy with Cancel (at least for Send)
and that is what's modified for use with Outlook 2000. But with VB6 code I
honestly can't see that as a problem.

Show the code for that entire class, if it's not too long, maybe something
will jump out.
 
A

Andrei Smolin [Add-in Express]

Hello Jack,

This can be an Outlook bug of course but I'd check the following
possibilities:

a) you can try closing the item in a timer event
b) if an inspector is listed in the Inspectors collection after you cancel
Item_Open, then try also closing the inspector
c) install the latest SP. For Outlook 2000 it is SP3
d) cut down your code in order to localize the issue

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
www.add-in-express.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top