Hi,
We have Add-ins constantly updated by replacing *.esriAddIn files on a network folder.
We know, that every time ArcMap starts, it copies from the network to a local AssemblyCache folder.
How to catch (programmatically) an event when an Add-In has finished loading in ArcMap? To make sure we working not with old but updated version of Add-ins.
Solved! Go to Solution.
yeah artificial clicks wouldn't be a good solution.
How about listening for the IApplicationStatusEvents.Initialized Event?
You would have to set that up in an extension, setting autoload to true. When that fires, all the addin UI components would have been loaded even if the code behind them hasn't. You could do your version checks in there.
You don't actually explain what sort of AddIn you have developed so there may be approaches more suited for your needs than others?
It's been quite a while since I developed an AddIn. I know extensions can listen out for application level events, I don't known if AddIns have those sort of event listeners. What I have done in the past because my Addin was simply a button that opened up a complex form was to have code that would check the map to see if it had at least one polyline layer, if it did then it would enable the button. This code was in the Protected Overrides Sub OnUpdate() procedure of the Button. You could try putting your version checking code in that?
Thanks Duncan,
They are Add-In buttons.
Yes, we use OnUpdate() method of an AddIn button. What about other Add-in buttons? Are you saying it must be their OnUpdate() method?
We only need to confirm that we working not with an old but with an updated version of each Add-in.
Nothing about a map.
Do you have any link to the official documentation confirming it?
Mark,
I would try putting your version checking code in anyone of the buttons. I don't think it needs to be in all of them. So as that button checks to see what state it should be in (enabled/disabled) it would also check the version. There is no official documentation, especially if you are already using onUpdate().
Mark,
You have a couple of options, depending on the onDemand flag in your config.
If its not specified or set to true (default), the add-in code isn't loaded until you interact with the control, in which case you can put the version check in the click event or even the add-in constructor.
If you have specified false then the add-in code is loaded when ArcMap starts. You could put the check in the constructor or in the OnUpdate override. Given that OnUpdate is called several times a second, its not an efficient place to put lengthy operations and is normally used for condition or state checks.
Setting OnDemand true in this case seems like an overkill so I would just go with the controls click event.
Where are you reading the version info from?
Thanks Sean,
System.Reflection.AssemblyName.GetAssemblyName(path_to_DLL).Version.ToString()
We are not sure what event to catch to be sure all Addins loaded last version(we have one network folder with *.esriAddIn files constantly updated)?
"Setting OnDemand true in this case seems like an overkill so I would just go with the controls click event."
Should we do artificial click events (we have >10 AddIns, >30 users)?
yeah artificial clicks wouldn't be a good solution.
How about listening for the IApplicationStatusEvents.Initialized Event?
You would have to set that up in an extension, setting autoload to true. When that fires, all the addin UI components would have been loaded even if the code behind them hasn't. You could do your version checks in there.
Hi Sean,
Is there a page which explains all the config setting options and what they do? I'm wondering if I have missed some golden nugget of information! I don't think I have ever found a page listing what the options are and what the implications are if you set them. I guess I've just not hit on the right search term?
Would be good if such a page exists.
Hi Duncan,
There's no definitive page for the xml schema unfortunately. You can glean a few things from the help pages, intellisense in Visual studio or trial and error. The xml reflects the initial choices from the new items wizard when creating the add-in controls.
Thanks Sean,
Exactly what we need. I will test it.