PC Review


Reply
Thread Tools Rate Thread

ApptItem_open

 
 
Jack
Guest
Posts: n/a
 
      14th Feb 2009
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


 
Reply With Quote
 
 
 
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      16th Feb 2009
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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Jack" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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
>


 
Reply With Quote
 
Jack
Guest
Posts: n/a
 
      16th Feb 2009
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


"Ken Slovak - [MVP - Outlook]" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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.
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Professional Programming Outlook 2007.
> Reminder Manager, Extended Reminders, Attachment Options.
> http://www.slovaktech.com/products.htm
>
>
> "Jack" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>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
>>

>



 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      16th Feb 2009
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?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Jack" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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


 
Reply With Quote
 
Jack
Guest
Posts: n/a
 
      17th Feb 2009
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?

"Ken Slovak - [MVP - Outlook]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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?
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Professional Programming Outlook 2007.
> Reminder Manager, Extended Reminders, Attachment Options.
> http://www.slovaktech.com/products.htm
>
>
> "Jack" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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

>



 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      17th Feb 2009
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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Jack" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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?


 
Reply With Quote
 
Andrei Smolin [Add-in Express]
Guest
Posts: n/a
 
      17th Feb 2009
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

"Jack" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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?
>
> "Ken Slovak - [MVP - Outlook]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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?
>>
>> --
>> Ken Slovak
>> [MVP - Outlook]
>> http://www.slovaktech.com
>> Author: Professional Programming Outlook 2007.
>> Reminder Manager, Extended Reminders, Attachment Options.
>> http://www.slovaktech.com/products.htm
>>
>>
>> "Jack" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> 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

>>

>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:44 PM.