Setup project events for add-in solutions based on Add-in Express
I have just thought, won’t I be awarded a Booker prize for the Blog devoted to our add-in Express? Sure, I won’t. Why then am I writing all this? Hmm… That is because I hate to write technical documentation. There’s no place there for my absolutely non-technical thoughts. And one can’t joke there. But here all this seems to be allowed. Besides, this Blog may help everybody who uses Add-in Express to gain better understanding. Especially me. :-) Ok, the time has come for setup projects for add-in solutions based on Add-in Express. This time I will be brief.
There’s only one thing here that you should take note of. It is custom actions. Add-in Express provides several events that allow executing some actions when installing and uninstalling the add-in. This feature is provided by a special installer, the references to which you can find in the custom actions of your setup projects
In addition to handling these events, this installer places Add-in Express assemblies to the GAC, counts the references to them and removes Add-in Express as soon as the last add-in using it has been removed. But these are not primary things for us. The most essential thing is what events we can use. All events pertaining to the installer are available via the add-in module. Here is their list:
- OnAfterInstall
- OnAfterRollback
- OnAfterUninstall
- OnAfterUninstallControls
- OnBeforeInstall
- OnBeforeRollback
- OnBeforeUninstall
- OnBeforeUninstallControls
- OnCommited
- OnCommiting
All the events, except for OnXXXControls, are standard, that’s why look for their descriptions in a description of the System.Configuration.Install.Installer class. The OnBeforeUninstallControls and OnAfterUninstallControls events are fired in uninstalling the add-in when the add-in controls are being removed. Both events are called for each host supported by the add-in. That is why their syntax is the following:
Public Event AfterUninstallControls (ByVal sender As Object, ByVal hostApp As _ AddinExpress.MSO.ADXOfficeHostApp, ByVal hostAppObj As Object) Public Event BeforeUninstallControls (ByVal sender As Object, ByVal hostApp As _ AddinExpress.MSO.ADXOfficeHostApp, ByVal hostAppObj As Object)
What can we use these events for? Sure, we may not use them at all. But I would recommend paying attention to them when you change standard command bars by replacing standard controls with your own ones. In this case, the use of these events allows you to restore standard command bars as is customary. I don’t know any other purposes for using these events. And since I don’t know, I won’t be awarded Booker Prize. :-)