Outlook 2000 stays in memory

Oct 24, 2012 at 4:33 AM

Hi SebastianDotNet.

First of, I think you did a great job with Netoffice!

Here's my problem:

I want to develop a com addin to work with Outlook 2000 - Outlook 2010.

Using your example - namely "COMAddinClassicExample" - I compiled, and registered the sample with "regasm".

Outlook starts fine, and the sample works displaying a message box on click.

But, when I close Outlook it just stays in memory.

To find out what's going on, I added message boxes to the events "OnDisconnection" and "OnBeginShutdown" in file "ExampleClassicAddin.cs".

Code snippets:


 void IDTExtensibility2.OnDisconnection(ext_DisconnectMode RemoveMode, ref Array custom)
            MessageBox.Show("OnDisconnection", "Testing", MessageBoxButtons.OK, MessageBoxIcon.Information);



void IDTExtensibility2.OnBeginShutdown(ref Array custom)
            MessageBox.Show("OnBeginShutdown", "Testing", MessageBoxButtons.OK, MessageBoxIcon.Information);

The rest of your sample code was left untouched.

I then recompiled, unregistered the first try, and registered the second one.

Neither message box is displayed, and Outlook just stays in memory...

I then took the com addin, and registered it on a machine having Outlook 2003 installed.

There the two message boxes do get displayed upon closing Outlook, and it gracefully disappears from memory.


Any ideas would be highly appreciated!

Thanks in advance!

With best regards


Oct 25, 2012 at 9:43 AM

did you use any events or its basicly the 1:1 example code?

for troubleshooting:
- remove or disable any other addins
- go to the application properties/debugging and use the option "start external program". insert the outlook.exe path.
now go the toolbar menu debugging/exceptions and hit the "checkbox Common Language Runtime Exceptions". now start debugging.
the debugger breaks if an exception is thrown.
- i can do a test but i need the information for your operating system and 32/64bit.


Oct 26, 2012 at 3:48 AM

Hi Sebastian,

thanks for your quick response.

Yes, I'm using exactly the sample code except the two message boxes mentioned before.

I checked checkbox "Common Language Runtime Exceptions" as advised, and started the project with the option "start external program".

Outlook starts, and I can click the "C# _ToolbarButton" receiving the corresponding message box.

When I close Outlook, no exception is thrown, Outlook is still visible as a process in "Task Manager", and the Visual Studio is still in Debugging mode.

I added variable "_outlookApplication" as a watch, and this is then simply grayed out.

Output from Debug is:

'OUTLOOK.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\mscorlib\\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'OUTLOOK.EXE' (Managed): Loaded 'C:\Downloads\NetOffice Release 1.4.1\NetOffice Release 1.4.1\Net2.0\Examples\Outlook\C#\COMAddinClassicExample\bin\Debug\OutlookClassicAddinCSharp.dll', Symbols loaded.
'OUTLOOK.EXE' (Managed): Loaded 'C:\Downloads\NetOffice Release 1.4.1\NetOffice Release 1.4.1\Net2.0\Examples\Outlook\C#\COMAddinClassicExample\bin\Debug\LateBindingApi.Core.dll', No symbols loaded.
'OUTLOOK.EXE' (Managed): Loaded 'C:\Downloads\NetOffice Release 1.4.1\NetOffice Release 1.4.1\Net2.0\Examples\Outlook\C#\COMAddinClassicExample\bin\Debug\OutlookApi.dll', No symbols loaded.
'OUTLOOK.EXE' (Managed): Loaded 'C:\Downloads\NetOffice Release 1.4.1\NetOffice Release 1.4.1\Net2.0\Examples\Outlook\C#\COMAddinClassicExample\bin\Debug\OfficeApi.dll', No symbols loaded.
'OUTLOOK.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Windows.Forms\\System.Windows.Forms.dll', No symbols loaded.
'OUTLOOK.EXE' (Managed): Loaded 'C:\Downloads\NetOffice Release 1.4.1\NetOffice Release 1.4.1\Net2.0\Examples\Outlook\C#\COMAddinRibbonExample\bin\Debug\OutlookRibbonAddinCSharp.dll', Symbols loaded.
'OUTLOOK.EXE' (Managed): Loaded 'C:\Downloads\NetOffice Release 1.4.1\NetOffice Release 1.4.1\Net2.0\Examples\Outlook\C#\COMAddinRibbonExample\bin\Debug\OfficeApi.dll', No symbols loaded.
'OUTLOOK.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System\\System.dll', No symbols loaded.
'OUTLOOK.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\\System.Configuration.dll', No symbols loaded.
'OUTLOOK.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Xml\\System.Xml.dll', No symbols loaded.
'OUTLOOK.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\\System.Drawing.dll', No symbols loaded.

When I then end debugging, Outlook disappears from memory.

OS is Windows XP Service Pack 3 32 bit

VS is

Microsoft Visual Studio 2005 Version 8.0.50727.42  (RTM.050727-4200)


Microsoft .NET Framework Version 2.0.50727 SP2

Installed Edition: Professional


Any ideas?!?



Oli ;-)

Oct 26, 2012 at 8:00 AM

i see you use an older version of NetOffice. can you do me a pleasure and update to please? its difficult for me to reproduce your scenario in a virtual machine with an old NetOffic version.

do you remove/disable other addins? the NetOffice developer toolbox contains a component called "Addin Guard" you see all addins here and you can temporaily disable them in the developer toolbox registry editor.

btw: a 30-60 seconds shutdown delay is typical for outlook because the application performs some backup operations for .pst files and some other.
i do a test now in a virtual machine. need 1 hour.


Oct 26, 2012 at 8:55 AM

update: i can reproduce the problem with outlook 200. the OnDisconnection/OnBeginShutdown events was not fired. if i remove the SetupGui() method then already was okay. i do some tests now with outlook 2002/2003 to see its a generic problem. need also 1 hour.


Oct 26, 2012 at 9:01 AM

update: the problem occurs only in Outlook 2000. i try to find a workarround now.


Oct 26, 2012 at 9:11 AM

i find a solution that works for me. change the SetupGui() method as follows:

private void SetupGui()
  Outlook._Explorer activeExplorer = _outlookApplication.ActiveExplorer();
  /* create commandbar */
  Outlook._Explorer activeExplorer = _outlookApplication.ActiveExplorer();
  Office.CommandBar commandBar = activeExplorer.CommandBars.Add(_toolbarName, MsoBarPosition.msoBarTop, System.Type.Missing, true);

  /// ....
   /* create menu */
  commandBar = activeExplorer.CommandBars["Menu Bar"];

   /// ...


you see we save the Active Explorer proxy in a local variable and dispose them at the end.
this is an outlook2000 issue and not a NetOffice issue i think.


Oct 26, 2012 at 11:51 AM

Good man!!!

and it works for me :-)

Thanks a lot!

Cheers Oli ;-)



Oct 26, 2012 at 12:30 PM

ooops no, it works not good because activeExplorer.Dispose(); release all childs(buttons and so on) and the events was not fired now.
but its easy to handle! please use activeExplorer.Dispose(false); // false means dont destroy the event listeners


Oct 27, 2012 at 4:19 AM

You're correct there. Thanks a bunch!

Cheers Oli ;-)