Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ThisAddIn_ShutDown doesn't execute

In my add-in for Outlook, I have the following lines.

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
  MessageBox.Show("Hazaa!");            
}

private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
  MessageBox.Show("Shazoo...");
}

While Outlook greets me with a cool "Hazaa!" upon its start, it refuses to go "Sahzoo..." on me when I', closing it. Both methods are registered in the same way using the default, auto-generated code, so I don't suspect any errors there. The other explanation I can think of is that the shutting down process is executed when the application already has left the GUI and the shazooing is hidden.

Is it so? If not, how can I make Outlook shazoo me? If so, how can I notify a user visually of such a shazoo?

EDIT:

Apparently, since O10, the shut down is no longer to be called, so the auto-generated code below is indeed wrong (or at least not perfect). Courtesy of @Christian.K.

#region VSTO generated code
private void InternalStartup()
{
  this.Startup += new System.EventHandler(ThisAddIn_Startup);
  this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
like image 237
Konrad Viltersten Avatar asked Jan 15 '23 15:01

Konrad Viltersten


1 Answers

Are you using Outlook 2010?

Starting in Outlook 2010, Outlook, by default, does not signal add-ins that it is shutting down. Specifically, Outlook no longer calls the OnBeginShutdown and OnDisconnection methods of the IDTExtensibility2 interface during fast shutdown. Similarly, an Outlook add-in written with Microsoft Visual Studio Tools for Office no longer calls the ThisAddin_Shutdown method when Outlook is shutting down.

like image 100
Christian.K Avatar answered Jan 25 '23 00:01

Christian.K