Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
405 views
in Technique[技术] by (71.8m points)

c# - 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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...