Application.Quit() method failing to clear process

Henry picture Henry · Jul 7, 2010 · Viewed 11k times · Source

I've seen a lot of posts returned from a Google search about this, but none of the solutions referenced in them clear this up for me. So, I thought I'd try myself.

After this block of code:

PowerPoint.Application powerPoint = new Microsoft.Office.Interop.PowerPoint.Application();
powerPoint.Visible = Office.MsoTriState.msoTrue;
Microsoft.Office.Interop.PowerPoint.Presentation ppt = null;enter code here

I can issue the ppt.Quit(); command and Powerpoint will close and no Process is left running.

However, if after this code I do this:

ppt = powerPoint.Presentations.Open(localCopyOfPPT,  
                                    Microsoft.Office.Core.MsoTriState.msoCTrue,
                                    Microsoft.Office.Core.MsoTriState.msoTriStateMixed,
                                    Microsoft.Office.Core.MsoTriState.msoTrue);
ppt.Close();
powerPoint.Quit();

Then, the Quit() won't work. Something about opening the presentation, even if I then close it, prevents the Quit() from working, it appears.

Anybody have any thoughts about how I can get the application to quit correctlY?

Answer

Chris Taylor picture Chris Taylor · Jul 7, 2010

The following KB Aritcle might help you get to the bottom of the problem. http://support.microsoft.com/kb/317109

You might need to explicity call System.Runtime.InteropServices.Marshal.ReleaseComObject on your ppt instance.