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


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.

Comments (3)

  1. Eric Carter says:

    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?