Unloading an Add-In

Hi,

I would like my add-in to load only after it had detected that another feature is installed on the local machine (this feature can be removed without notice, hence we do not check it existence while installing the add-in). If the feature isn't there i would like to display a message to the user and unload the Add-In.

Where is the best place to put this validation code I tried using it on the OnConnection event handler, but when i instruct the Add-In to diconnect (connected=false) i end up seeing an error generated by VS. Is there an example on how to do that

Thank you in advance,

Ariel



Answer this question

Unloading an Add-In

  • BrandonM

    Yes I completely agree with Craig. First thing that struck me when I read your post is why to unload the add in Instead, do not implement any functionality if you do not find your feature and let the add-in unload when you host app closes.
  • jpx

    Thank you both for your suggestions

    Ariel


  • Wolfgang Kamir

    Setting the Connected property to false in the OnConnection method does not work that well since we expect it to be loaded upon return, so we fail any calls after Connected=false.

    The best way to deal with this is to disable any functionality of your Add-in if the feature is not available. In your scenario it seems like this functionality could or could not be there, and it could be added/removed by the user at will. Trying to coordinate this in a way that would work and make sure your component is available when the feature is available would be too complicated. I would just gracefully return, have an error message, and enable/disable your commands through QueryStatus depending on what the status of this feature is.

    Craig



  • Unloading an Add-In