What do I put in a VSTO Outlook Add In shutdown handler?
-
I'm writing my first VSTO Outlook add-in. Basically "Hello World". It's VS 2008 targeting Outlook 2007. It's a standard MS VS build/publish. In the startup handler I've got:
try
{
Office.CommandBar commandBar = activeExplorer.CommandBars["Standard"];
button = (Office.CommandBarButton)commandBar.Controls.Add(1, missing, missing, missing, missing);
button.Style = Office.MsoButtonStyle.msoButtonCaption;
button.Caption = "TEST";
button.Tag = "btnProcess";
//button.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(button_Click);
return true;
}
catch (ArgumentException e)
{
MessageBox.Show(e.Message);
}'button' is a local Office.CommandBarButton object. It installs nicely and puts a 'TEST' button on the standard toolbar as expected. But when I uninstall via Control Panel, the button is still there when I restart Outlook. I guess I need something in the shutdown handler to kill the button - but what? Office.CommandBarButton class does not have a dispose event. How come the button is still there after uninstallation, and how do I solve that? I'm a bit confused here. Help!
JustAStupidGurl