Monday, October 11, 2004

Getting Outlook to shut down [when you create a managed add-in]

Getting Outlook to shut down

"I’ve had a number of people ask me how to get Outlook to shutdown properly when you create a managed add-in for it. I alluded to this issue briefly in my last blog. The OnDisconnection method you implement in your add-in’s implementation of IDTExtensibility2 doesn’t get called if you have outstanding variables that are still holding Outlook objects.

The secret to getting OnDisconnect called and your add-in unloaded is to listen to Explorer & Inspector close events, and when the last Explorer or Inspector has closed, you make sure you set all the variables that are holding Outlook objects to null. I also force a garbage collection after setting the variables to null to ensure that my add-in isn’t holding onto Outlook objects because of objects still waiting to be garbage collected.

Here is a little helper class that I wrote that you can create from your main Connect class in an add-in. ..."

Some good information for when I get to writing Outlook add-ins in .Net.

No comments:

Post a Comment

NOTE: Anonymous Commenting has been turned off for a while... The comment spammers are just killing me...

ALL comments are moderated. I will review every comment before it will appear on the blog.

Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...

I reserve, and will use, the right to not approve ANY comment for ANY reason. I will not usually, but if it's off topic, spam (or even close to spam-like), inflammatory, mean, etc, etc, well... then...

Please see my comment policy for more information if you are interested.

Thanks,
Greg

PS. I am proactively moderating comments. Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...