1

I need execute a function that init a timer when ArcMap application start. My extension class:

namespace GMREAddin.Modules.Toolbar
{
    public sealed class eManager : ESRI.ArcGIS.Desktop.AddIns.Extension
    {
       protected override void OnStartup()
       {
            MessageBox.Show("opened from onstartup.");
            initTimer();
       }
    }
}

And have this attribute in the configuration enter image description here

When I run the application, it doesn't display the message, and does not start the message.

I am using version 10.4.

1 Answer 1

2

According to ArcMap add in constructor called not called on start up it looks like you need to add a 'delayLoad' attribute to your extension and set it to false. Then also keep autoLoad = "true".

I created an empty sample project and tested this code. The config extension looks like this and it seems to work:

<ArcMap>
  <Extensions>
    <Extension id="ArcMapAddin1_Extension1" class="Extension1" delayLoad="false" autoLoad="true" />
  </Extensions>
</ArcMap>

And then I have a MessageBox in the OnStartup() method which appears as soon as ArcStarts.

protected override void OnStartup()
{
   MessageBox.Show("Loaded");
}
5
  • I get the message: The 'delayLoad' attribute is not declared. And in the post isn't that attribute
    – Pilgrim
    Commented May 5, 2017 at 18:16
  • I edited my answer with the test I ran for this. What version of ArcMap are you running? The example above is 10.2.
    – danielm
    Commented May 5, 2017 at 18:29
  • I run the version 10.4
    – Pilgrim
    Commented May 5, 2017 at 18:54
  • Okay, when using 10.4 I also see the 'attribute is not declared' error, but I can still build and run the add-in. Is it preventing you from building your add-in?
    – danielm
    Commented May 5, 2017 at 20:33
  • No, my application run. But the event doesn't work.
    – Pilgrim
    Commented May 6, 2017 at 22:24

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.