views:

428

answers:

3

I am running into problems with an Outlook Add In I created. Somehow Outlook doesn't shut down properly. I've seen all the postings about using ReleaseComObject and such.

==== UPDATE ====

I tried the whole thing again, creating a new empty project in a new solution and now, after some time after shutting down Outlook the following Error message is presented to me in Visual Studio. Somehow I think I must have disabled getting that exception in the previous solutions. I don't know what it means (yet) but I will go for a hunt. Maybe this will shine some light on the issue? The effect is still the same: Outlook doesn't shut down.

ContextSwitchDeadlock was detected Message: The CLR has been unable to transition from COM context 0x55cdd8 to COM context 0x55cf48 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.

Also when I try to remove the add in when not in safe mode (e.g. it has been loaded) Oulook locks up when hitting the remove button in the safe center). Guess that's the same cause though.

===== END OF UPDATE ====

To debug what's going on I did the simplest thing imaginable:

1) Using Visual Studio 2008 I created a new Outlook 2007 Add In Project

2) I started the debugger with the new add in.

3) After some time I close down Outlook, expecting it to properly close down.

It doesn't. The code does reach the generated ThisAddIn_Shutdown method. But, Outlook doesn't shut down.

To make sure I'm not completely insane, I downloaded, compiled and tried the extensive example found at http://code.msdn.microsoft.com/ContosoAutoOBA. Using this add in has the same effect: Outlook doesn't close down.

I tried this with no other add ins available: that doesn't make a difference.

Just for the record, below you find the generated code.

I'm using Windows 7, Visual Studio 2008, Office 2007, all updates are installed.

Is there someone that can shine a light on this. You help is greatly appreciated.

Thanks,

Bart

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;
namespace OutlookAddIn3
{
    public partial class ThisAddIn
    {
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
        }
        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
        {
        }
    #region VSTO generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InternalStartup()
        {
            this.Startup += new System.EventHandler(ThisAddIn_Startup);
            this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
        }
    #endregion
    }
}
A: 

Ah the days of VSTO development!

From memory - to fix this:

  1. Close all instances of Outlook running (Task Manager, End Process)
  2. Start the application by using the debug button in VS.NET

From memory; it plays up a bit when there was already an instance running.

Paul Mason
I'm afraid that isn't it. The problem also exists when started outside of Visual Studio. And it doesn't matter if I press the button or press F5.
Bart Roozendaal
A: 

Hi, First up. What version of the office service pack are you running. There are loads of fixes in SP2 to help shutdown.

Are you saying that if you dont have the addin installed outlook shuts down ok ? As I wonder if you have any other installed inder trust center. ?

76mel
I'm running SP2, Windows is up to date too. Yes, if I don't have the addin installed Outlook shuts down ok. I also tried removing everything else from the trust center. That doesn't help. I tried it on another PC and it has the same effect. Having that empty add in installed simply stops Outlook from shutting down.
Bart Roozendaal
A: 

It appears that the Microsoft CRM Add In is the problem. I disabled it earlier (in fact disabled all Outlook plug ins), but apparently that isn't enough. Actually removing it from my computer solved the problem.

There seems to be a update 7 roll up for the Microsoft CRM plugin, but it refuses to install on my machine. Alas, at least I can continue with my own Outlook plug in. I will keep a post it on my screen from now own as my new CRM system.

Bart Roozendaal
Yes you have to remove them as some will load on demand. Gald you got sorted
76mel