2

I'm currently writing an application-level addin for Powerpoint 2010, and my problem is that when I close the application, the process remains in memory. I only open one instance of Powerpoint at a given time.

i think the problem lies in the way I treat the objects in my addin, but I can't find what's wrong. Maybe I need to do something special to properly dispose of them?

In my addin, I use the following objects. The ones with "UPnP" in the type are instantiated from Intel's UPNP library. These instruction are in my Ribbon1 class, before any functions or subs.

Public dispositivo As UPnPDevice
Public servicio As UPnPService
Public WithEvents temporizador As Timers.Timer
Public WithEvents aplicacion As New Application
Public presentacion As Presentation
Public presentacionencurso As SlideShowView
Public diapositiva_actual As Slide
Public notas As SlideRange
Public puntero As Shape

I've scourged Google looking for answers and nothing comes up.

000
  • 26,951
  • 10
  • 71
  • 101
Léster
  • 1,177
  • 1
  • 17
  • 39

2 Answers2

2

You need to handle ThisAddIn_Shutdown and properly dispose of all COM handles (events, RCW, etc.) and other unmanaged resources.

Read this reference on proper COM object disposal and this MSDN post for shutdown best practices.

If Powerpoint stays running than you are not properly releasing all COM handles.

SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173
1

It could be that you are creating a new instance of Powerpoint when you declare your variable "aplicacion":

Public WithEvents aplicacion As New Application

The events should all be available within the ThisAddIn module (use the pull down menus under the ThisAddIn document tab in the editor) and you can always refer to the Powerpoint app using "Globals.ThisAddIn.Application" so perhaps you want to do this instead:

Public aplicacion as Microsoft.Office.Interop.PowerPoint.Application = Globals.ThisAddIn.Application

Buena suerte!

Sam Russo
  • 422
  • 4
  • 8
  • Right on the spot. I moved all my logic to the ThisAddIn module (the retarded in me implemented everything on the Ribbon class), removed the **aplicacion** object and used the automatically provided **Application** object instead. Everything worked without a problem. – Léster Aug 31 '12 at 17:33