4

I am converting some old tools to the new Add-In format and have noticed that the constructor is no longer being called during startup, instead it is being called when the tool is clicked for the first time (second and subsequent call OnActivate only).

This particular tool is in a toolbar add-in and is of type ESRI.ArcGIS.Desktop.AddIns.Tool and should only be enabled if ArcMap is currently editing. Previously the constructor was called and set the tool.enabled = false arbitrarily (as you can't be editing on startup) and added an event handler for IEditEvents_OnStartEditingEventHandler which set the too.enabled = true (and stop editing too, enabled = false).

Now that the tool is made into an add in I discovered by step-debugging that the constructor for the tool isn't called until the tool is clicked. After clicking the tool behaves in the intended manner as the events are wired. Is there a way to call the constructors during ArcMap startup, soon after or does anybody know of any other workaround?

1 Answer 1

4

In config.esriaddinx, set the tool's onDemand property to false. Similarly, if you have any extensions that need to be initialized at startup, set its autoLoad property to true.

4
  • I'm not seeing that property, is it something that I could add? Commented Apr 29, 2014 at 3:05
  • Yes, try adding it if it's not there.
    – blah238
    Commented Apr 29, 2014 at 3:08
  • That did it thank you @blah238! the use of the onDemand and autoLoad is optional. I inserted the properties onDemand="false" autoLoad="true" on the line that started <Tool id= and it ran the constructor as before. Commented Apr 29, 2014 at 3:15
  • Only onDemand applies to Tools so you can remove autoLoad (applies to extensions).
    – blah238
    Commented Apr 29, 2014 at 4:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.