Add-in: extension not loaded

3010
4
Jump to solution
05-22-2012 10:55 AM
RodrigoSalvador
New Contributor
Hi all

I have just built a simple add-in, in order to migrate my application to this new architecture. This add-in has two toolbars, and I can see both of then when I run ArcMap. There's also an extension, but the Startup method is never called. Does anyone faced some issue like that?
Before it, I've tried do work registering dlls. I've faced the same difficult, but it worked - unfortunately, I have no idea why it wasn't working, neither why it suddenly acess the class that inherited IExtension.

Thanks in advance

Rodrigo Salvador
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor
Here's what the Extensions node looks like in my config.esriaddinx file. Take a look at the Converting Extension section of this Help page for more information

      <Extensions>         <Extension id="Biogeography_Branch_HabitatDigitizer_10_Extension" class="Extension" productName="Habitat Digitizer" showInExtensionDialog="true" autoLoad="true">           <Description>The Habitat Digitizer Extension was designed to use a hierarchical classification scheme to attribute polygons, lines, and points delineated by visually interpreting georeferenced images such as aerial photographs, satellite images, and side scan sonar. The extension allows users to create custom classification schemes and rapidly delineate and attribute polygons, lines, and points using simple menus and dialogs.</Description>         </Extension>       </Extensions> 

View solution in original post

0 Kudos
4 Replies
KenBuja
MVP Esteemed Contributor
What does your Config.esriaddinx and Extension code look like?
0 Kudos
RodrigoSalvador
New Contributor
Hi Ken

Thanks for your attention. I didn't make any changes in Config.esriaddinx, I've let it just the way the wizard created it. The "Extension1" class differs from de default onde only by some message boxes inside the constructos, startup and event handle methods. Here they are:

Extension1 class
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Windows.Forms;

namespace GEOTE_Addin
{
    public class Extension1 : ESRI.ArcGIS.Desktop.AddIns.Extension
    {
        public Extension1()
        {
            MessageBox.Show("Constructor method Extension1 reached...");
        }

        protected override void OnStartup()
        {
            MessageBox.Show("OnStartup method reached!");
            WireDocumentEvents();
        }

        private void WireDocumentEvents()
        {
            //
            // TODO: Sample document event wiring code. Change as needed
            //

            // Named event handler
            ArcMap.Events.NewDocument += delegate() { ArcMap_NewDocument(); };
            ArcMap.Events.OpenDocument += delegate() { ArcMap_OpenDocument(); };

            // Anonymous event handler
            ArcMap.Events.BeforeCloseDocument += delegate()
            {
                // Return true to stop document from closing
                ESRI.ArcGIS.Framework.IMessageDialog msgBox = new ESRI.ArcGIS.Framework.MessageDialogClass();
                return msgBox.DoModal("BeforeCloseDocument Event", "Abort closing?", "Yes", "No", ArcMap.Application.hWnd);
            };

        }

        void ArcMap_NewDocument()
        {
            // TODO: Handle new document event
        }

        void ArcMap_OpenDocument()
        {
            MessageBox.Show("You opened a doc");
        }
    }

}


Config.esriaddinx (2 buttons, 2 menus, 2 toolbars, 1 extension)

<ESRI.Configuration xmlns="http://schemas.esri.com/Desktop/AddIns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Name>GEOTE_Addin</Name>
  <AddInID>{135b6f77-cc81-4a52-9b13-644d6427dbc1}</AddInID>
  <Description>Extensão do GEO-TE</Description>
  <Version>1.0</Version>
  <Image>Images\GEOTE_Addin.png</Image>
  <Author>Salvador</Author>
  <Company>COPEL</Company>
  <Date>21/05/2012</Date>
  <Targets>
    <Target name="Desktop" version="10.0" />
  </Targets>
  <AddIn language="CLR" library="GEOTE_Addin.dll" namespace="GEOTE_Addin">
    <ArcMap>
      <Extensions>
        <Extension id="GEOTE_Addin_Extension1" class="Extension1" />
      </Extensions>
      <Commands>
        <Button id="GEOTE_Addin_ArcGISAddin1" class="ArcGISAddin1" message="Add-in command generated by Visual Studio project wizard." caption="My Button" tip="Add-in command tooltip." category="Add-In Controls" image="Images\ArcGISAddin1.png" />
        <Button id="GEOTE_Addin_ArcGISAddin2" class="ArcGISAddin2" message="Add-in command generated by Visual Studio project wizard." caption="My Button" tip="Add-in command tooltip." category="Add-In Controls" image="Images\ArcGISAddin2.png" />
      </Commands>
      <Menus>
        <Menu id="GEOTE_Addin_Menu_A" caption="Menu A" isRootMenu="false">
          <Items />
        </Menu>
        <Menu id="CGEOTE_Addin_Menu_B" caption="Menu B" isRootMenu="false">
          <Items />
        </Menu>
      </Menus>
      <Toolbars>
        <Toolbar id="GEOTE_Addin_Toolbar_Z" caption="Toolbar Z" showInitially="false">
          <Items />
        </Toolbar>
        <Toolbar id="GEOTE_Addin_Toolbar_Y" caption="Toolbar Y" showInitially="true">
          <Items />
        </Toolbar>
      </Toolbars>
    </ArcMap>
  </AddIn>
</ESRI.Configuration>
0 Kudos
KenBuja
MVP Esteemed Contributor
Here's what the Extensions node looks like in my config.esriaddinx file. Take a look at the Converting Extension section of this Help page for more information

      <Extensions>         <Extension id="Biogeography_Branch_HabitatDigitizer_10_Extension" class="Extension" productName="Habitat Digitizer" showInExtensionDialog="true" autoLoad="true">           <Description>The Habitat Digitizer Extension was designed to use a hierarchical classification scheme to attribute polygons, lines, and points delineated by visually interpreting georeferenced images such as aerial photographs, satellite images, and side scan sonar. The extension allows users to create custom classification schemes and rapidly delineate and attribute polygons, lines, and points using simple menus and dialogs.</Description>         </Extension>       </Extensions> 
0 Kudos
RodrigoSalvador
New Contributor
Ken

Your Extension tag really helped me here. The following instructions were not inside my tag:
showInExtensionDialog="true" autoLoad="true"


So, copying it to my code, it's all working fine. I was guessing it could be started with the add in wizard, but now it's ok.

I really appreciate your help. Thanks a lot.

Rodrigo Salvador
0 Kudos