Welcome to MSDN Blogs Sign in | Join | Help

.NET4Office

A blog by Eric Carter
More on getting Outlook to shut down

I recently posted some code showing how to get Outlook to shut down.

I contended that you shouldn't have to call ReleaseCOMObject as is shown in some MSDN articles to get Outlook to shut down.

Indeed, David Mortenson who has worked on interop here at Microsoft warns further about ReleaseCOMObject.

One other point that David has made relating to the technique I showed for getting Outlook to shutdown (set variables containing Outlook OM objects to null and force a garbage collection and ) is that you actually sometimes have to write this code.

// Set objects using Outlook OM objects to null

GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();

For my simple example where the objects I was setting to null were just variables pointing to Outlook OM objects, you wouldn't have to do this, but if you are setting a class to null which has a finalizer and that class has a variable containing an Outlook OM object, you would have to do this to make sure that class releases all it's OM objects it is holding on to.

Posted: Wednesday, October 20, 2004 3:48 PM by Eric Carter

Comments

Chris Kunicki said:

# October 20, 2004 9:32 PM

Eric Carter said:

Sweet. You know what drives me nuts is when I start up my PocketPC ActiveSync application before I launch Outlook. ActiveSync launches Outlook in "inviso-mode". Then, the only way to get the Outlook window to be visible is to kill the inviso-mode Outlook and relaunch it.

Anybody know how to work around this issue? Maybe this utility does the trick?
# October 20, 2004 10:28 PM

Tim Hibbard said:

# October 27, 2004 5:50 PM
New Comments to this post are disabled
Page view tracker