destroying Explorer object pointers on shutdown

Status
Not open for further replies.
R

R2FicmllbA

Another newbie question here. I'm writing an ATL/COM add-in for Outlook 2003.

When quitting Outlook, I was getting an "abnormal program termination" error.

If I understand correctly, this is probably a result of not releasing my

Explorer object pointer? I added a sink for the explorer close event as

recommended but I guess I have to do something other than just set my pointer

to NULL?

(My pointer is: CComPtr <Outlook::_Explorer> m_spExplorer;)

Here's my code (checking to see if this is the last :

// gives an "assertion failed" error

void _stdcall CAddin::OnExplorerClose(){

CComPtr <Outlook::_Explorers> spExplorers;

m_spApp->get_Explorers(&spExplorers);

long count;

spExplorers->get_Count(&count);

if (count == 1){

spExplorerEvents::DispEventUnadvise((IDispatch*)m_spExplorer);

spExplorerEvents2::DispEventUnadvise((IDispatch*)m_spExplorer);

spExplorerEvents3::DispEventUnadvise((IDispatch*)m_spExplorer);

m_spExplorer = NULL;

}

}

As always, any assistance is greatly appreciated.

-Gabriel
 
K

Ken Slovak - [MVP - Outlook]

The algorithm is to check in the Close() event for that being the final

Explorer and no Inspectors. Then you have to release all your Outlook object

pointers, not just Explorers. If you have handles to Application, NameSpace,

etc. they all must be released.

"Gabriel" <Gabriel> wrote in message

news:EE559A29-9E33-41AE-8CC9-9E53C54E8953@microsoft.com...
> Another newbie question here. I'm writing an ATL/COM add-in for Outlook
> 2003.
> When quitting Outlook, I was getting an "abnormal program termination"
> error.
> If I understand correctly, this is probably a result of not releasing my
> Explorer object pointer? I added a sink for the explorer close event as
> recommended but I guess I have to do something other than just set my
> pointer
> to NULL?

> (My pointer is: CComPtr <Outlook::_Explorer> m_spExplorer;)

> Here's my code (checking to see if this is the last :

> // gives an "assertion failed" error
> void _stdcall CAddin::OnExplorerClose(){

> CComPtr <Outlook::_Explorers> spExplorers;

> m_spApp->get_Explorers(&spExplorers);

> long count;

> spExplorers->get_Count(&count);

> if (count == 1){

> spExplorerEvents::DispEventUnadvise((IDispatch*)m_spExplorer);

> spExplorerEvents2::DispEventUnadvise((IDispatch*)m_spExplorer);

> spExplorerEvents3::DispEventUnadvise((IDispatch*)m_spExplorer);

> m_spExplorer = NULL;

> }

> }

> As always, any assistance is greatly appreciated.

> -Gabriel
 
R

R2FicmllbA

Hi Ken,

Thanks for the input. Turns out I'd erroneously added

"m_spExplorer->Close()" to the OnBeginShutdown method when I was first

troubleshooting so I didn't notice one error being replaced by another

similar one (since of course by the time it was called I'd already released

it). Guess it pays to actually read those assertions!

Thanks again,

-Gabriel
wrote:


> The algorithm is to check in the Close() event for that being the final
> Explorer and no Inspectors. Then you have to release all your Outlook object
> pointers, not just Explorers. If you have handles to Application, NameSpace,
> etc. they all must be released.

> >

>

>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
K Working with Explorer.Close event Outlook VBA and Custom Forms 3
R Quick Access view in File Explorer when saving attachments Using Outlook 0
R Sending emails via Outlook XP, from Windows 10 File Explorer Using Outlook 1
P Automate Outlook Start - No Active Explorer Object Found Using Outlook 10
K Macro Not Executing then send email from Explorer Outlook VBA and Custom Forms 3
I Windows 10 - .msg files on disk show Explorer popup error Using Outlook 5
M Question: Is there a rule that will save email in Windows Explorer Outlook VBA and Custom Forms 3
oliv- How to select an mailitem in explorer with "show as conversation" Outlook VBA and Custom Forms 8
Michael Chiasson PST file shows 300+MB in Windows Explorer, but only 250kb in Outlook 2010 Using Outlook 1
P Was Helvetica crashing Outlook, now fix has messed up explorer Using Outlook 4
R Outlook 2007 - drag drop email to Explorer Using Outlook 1
A vb6 run time error 5 when Outlook 2007 Explorer object displayed Outlook VBA and Custom Forms 1
C Create a Ribbon for the OL2010 Explorer Outlook VBA and Custom Forms 1
E Can I hide an explorer or make an explorer modal Outlook VBA and Custom Forms 2
E Can I hide an explorer or make an explorer modal Outlook VBA and Custom Forms 2
A Active explorer issue Outlook VBA and Custom Forms 15
S How to italicize the email entry in explorer window Outlook VBA and Custom Forms 3
T Creating toolbar in new Explorer Outlook VBA and Custom Forms 3
S Strange Behaviour of Explorer Object. Outlook VBA and Custom Forms 1
T Is Explorer.FolderSwitch the best event for hiding commandbarbutton? Outlook VBA and Custom Forms 5
U Not able to delete Add-in button from multiple Outlook Explorer Outlook VBA and Custom Forms 1
R How to get the Items object of the default mailbox of a specific account in a multiple account Outlook? Outlook VBA and Custom Forms 0
A Run time error 424. object required in outlook 2013 Outlook VBA and Custom Forms 10
vodkasoda Object could not be found Error in Outlook 2007 Outlook VBA and Custom Forms 5
S VBA Macro - Run-time error '424': object required - Help Please Outlook VBA and Custom Forms 3
J Object Variable or With Block Not Set Error in Outlook 2016 and not Outlook 2013 Outlook VBA and Custom Forms 3
R Macro to copy email to excel - Runtime Error 91 Object Variable Not Set Outlook VBA and Custom Forms 11
J Outlook 2016 is killing me with object.links Outlook VBA and Custom Forms 2
S how to access the properties of a contact given distlist.member object Outlook VBA and Custom Forms 1
J An attempt operation failed. An object could not be found at line5. Outlook VBA and Custom Forms 2
R How can I retain embedded object with voting button reply? Using Outlook 5
G run-time 438: object doesn't support this property or method Using Outlook 2
B Task List in To-Do Bar 'The operation failed. An object could not be found' Using Outlook 3
P Problem with a Search-Object resulting from an AdvancedSearch Outlook VBA and Custom Forms 2
T How to get Inspector object from Window handle Outlook VBA and Custom Forms 2
M MailItem object has no property for when a reply was sent Outlook VBA and Custom Forms 3
T Complete the object model Outlook Wishlist 0
M Outlook Contact Object: Is there a "last accessed" date-time prope Outlook VBA and Custom Forms 3
M Cannot Send - "Operation failed. An object cannot be found" BCM (Business Contact Manager) 4
K How to disconnect Application.COMAddIns.Item().Object? Outlook VBA and Custom Forms 4
S RDOMail object is not working in different thread. Outlook VBA and Custom Forms 13
G Error in Outlook Object Model with redemption and google apps prem Outlook VBA and Custom Forms 3
C Unable to cast object of type 'System.Int32' to type 'System.Byte[ BCM (Business Contact Manager) 1
S UserProperties of MailItem object. Outlook VBA and Custom Forms 3
P UserProperty of mail object problem while dealing with custom fold Outlook VBA and Custom Forms 2
J object that has been separated from its underlying RCW Outlook VBA and Custom Forms 11
S How to get RFC822 format message from the MailItem object. Outlook VBA and Custom Forms 4
B Compile error: Object required Outlook VBA and Custom Forms 2
R Unable to cast COM object" error Outlook VBA and Custom Forms 2
R Unable to cast COM object" error Outlook VBA and Custom Forms 5

Similar threads

Top