Outlook Addin does not shutdown properly when BCM is used

C

Cedric

Hello,

We have many problems because Outlook doesn't shutdown properly.
We are using Outlook 2007 with BCM + Exchange 2007.

With the following addin (written in C# with Visual Studio 2008) , Outlook
2007 shut downs properly as expected.
As soon as the BCM addin is also activated, Outlook 2007 doesn't shutdown
any more.

Could you please fix this bug? Is there a workaround?

Thanks,
Cedric

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 OutlookAddInDoesNotShutdown
{
public partial class ThisAddIn
{
private Outlook.NameSpace nameSpace = null;

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
nameSpace = this.Application.GetNamespace("MAPI");
}

private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
nameSpace = null;
GC.Collect();
}

#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
}
}
 
L

Luther

Hello,

We have many problems because Outlook doesn't shutdown properly.
We are using Outlook 2007 with BCM + Exchange 2007.

With the following addin (written in C# with Visual Studio 2008) , Outlook
2007 shut downs properly as expected.
As soon as the BCM addin is also activated, Outlook 2007 doesn't shutdown
any more.

Could you please fix this bug? Is there a workaround?

Thanks,
Cedric

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 OutlookAddInDoesNotShutdown
{
    public partial class ThisAddIn
    {
        private Outlook.NameSpace nameSpace = null;

        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            nameSpace = this.Application.GetNamespace("MAPI");
        }

        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
        {
            nameSpace = null;
            GC.Collect();
        }

        #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
    }



}- Hide quoted text -

- Show quoted text -

Usually these kinds of problems are because a reference to an object
is not being released.

You appear to be doing the right thing in ThisAddIn_Shutdown setting
the namespace to null and calling garbage collection, which I
assume(?) will internally call Dispose on nameSpace.

I take it Outlook shut's down if your addin does not get the MAPI
namespace?
 
C

Cedric

Hello,

Yes this is basically getting a reference & dereferencing the Mapi Namespace:

Startup:
nameSpace = this.Application.GetNamespace("MAPI");
Shutdown:

nameSpace = null;

Please not that this is exactly the same with this.Application.Session

Of course, our addins are much more complicated, but I could trace back the
problem to that single reference.

Again, what is unnerving is that it only fails when BCM is loaded.
It does not fail in Outlook 2007 without BCM, it shutdowns properly as it
should.

Cedric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top