ThisAddIn_ShutDown does not 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 cool "Haza!" from the very beginning, he refuses to go β€œSahzu ...” to me when I close it. Both methods are registered in the same way using the automatically generated code by default, so I don’t suspect any errors. Another explanation, about which I can think of is that the closing process is executed when the application has already left the GUI and shazooing is hidden.

This is true? If not, how can I make Outlook shazoo me? If so, how can I notify the user visually about such a shazoo?

EDIT:

Apparently, since O10, shutdown ceases to be called, so the automatically generated code below really 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 
+4
source share
2 answers

Are you using Outlook 2010 ?

Starting with Outlook 2010, Outlook by default does not signal the add-in that it is closing. In particular, Outlook no longer calls the OnBeginShutdown Methods and OnDisconnection IDTExtensibility2 interface during quick shutdowns. Similarly, an Outlook add-in written with Microsoft Visual Studio Tools for Office no longer causes ThisAddin_Shutdown when Outlook closes.

+5
source

If you use Outlook 2010, you can ask Outlook to inform your plugin when it shuts down.

 [RequireShutdownNotification]=dword:0x1 

The key must be placed in the registry folder of your plugin

+4
source

Source: https://habr.com/ru/post/1432868/


All Articles