2

A fellow c# developer developed a ArcMap AddIn, but he has now left the business.

I have acquired his laptop with the VS2010 and ArcMap 10.1. I can create the Esri Addin File. Import it into the '~/Documents/ArcGIS/AddIns/Desktop10.1' folder.

It works fine on his machine.

I have installed ArcMap10.1 and the .netFramework on my PC imported the Addin File into the same folder. But the command button does not appear, so I cannot select it.

it appears in my extension list and is selected. it appears in my add-In Manager but still the button does not appear when I search for it in the command list.

Please can someone point me in the right direction as to figuring this one out. I think that something is not installed but I cannot figure out what that may be.

The Config.esriaddinx file

  <ESRI.Configuration xmlns="http://schemas.esri.com/Desktop/AddIns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Name>****.ArcMapAddin.Bins</Name>
  <AddInID>{d64bdedc-d036-4aa3-9b1e-77129a2359bf}</AddInID>
  <Description>Collections Plugin</Description>
  <Version>1.0</Version>
  <Image>Images\****.ArcMapAddin.Bins.png</Image>
  <Author>**********</Author>
  <Company>*************</Company>
  <Date>25/02/2014</Date>
  <Targets>
    <Target name="Desktop" version="10.1" />
  </Targets>
  <AddIn language="CLR" library="****.ArcMapAddin.Bins.dll" namespace="****.ArcMapAddin.Bins">
    <ArcMap>
      <Extensions>
        <Extension id="*************.ArcMapAddin.Bins_ExtensionBins" class="ExtensionBins" productName="ArcMap.Bins" showInExtensionDialog="true" autoLoad="true" />
      </Extensions>
    </ArcMap>
  </AddIn>
</ESRI.Configuration>

The BaseCommandOpenBinsDialog.cs

using System;
using System.Drawing;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.ADF.CATIDs;
using ESRI.ArcGIS.Framework;
using ESRI.ArcGIS.ArcMapUI;
using System.Collections.Generic;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Carto;
using System.Linq;
using System.Windows.Forms;

namespace ****.ArcMapAddin.Bins
{
    /// <summary>
    /// Summary description for BaseCommandOpenBinsDialog.
    /// </summary>
    [Guid("aea6924a-f7d7-4c83-84c7-898c63a04d82")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("****.ArcMapAddin.Bins.BaseCommandOpenBinsDialog")]
    public sealed class BaseCommandOpenBinsDialog : BaseCommand
    {
        #region COM Registration Function(s)
        [ComRegisterFunction()]
        [ComVisible(false)]
        static void RegisterFunction(Type registerType)
        {
            // Required for ArcGIS Component Category Registrar support
            ArcGISCategoryRegistration(registerType);

            //
            // TODO: Add any COM registration code here
            //
        }

        [ComUnregisterFunction()]
        [ComVisible(false)]
        static void UnregisterFunction(Type registerType)
        {
            // Required for ArcGIS Component Category Registrar support
            ArcGISCategoryUnregistration(registerType);

            //
            // TODO: Add any COM unregistration code here
            //
        }

        #region ArcGIS Component Category Registrar generated code
        /// <summary>
        /// Required method for ArcGIS Component Category registration -
        /// Do not modify the contents of this method with the code editor.
        /// </summary>
        private static void ArcGISCategoryRegistration(Type registerType)
        {
            string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
            MxCommands.Register(regKey);

        }
        /// <summary>
        /// Required method for ArcGIS Component Category unregistration -
        /// Do not modify the contents of this method with the code editor.
        /// </summary>
        private static void ArcGISCategoryUnregistration(Type registerType)
        {
            string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
            MxCommands.Unregister(regKey);

        }

        #endregion
        #endregion

        private class ArcMapWindow : System.Windows.Forms.IWin32Window
        {
            private IApplication m_app;

            public ArcMapWindow(IApplication application)
            {
                m_app = application;
            }

            public System.IntPtr Handle
            {
                get { return new IntPtr(m_app.hWnd); }
            }

        }

        private IApplication m_application;
        public BaseCommandOpenBinsDialog()
        {
            //
            // TODO: Define values for the public properties
            //
            base.m_category = "*************************"; //localizable text
            base.m_caption = "Bins";  //localizable text
            base.m_message = "Open Bins Dialog Box";  //localizable text 
            base.m_toolTip = "Configure Bins";  //localizable text 
            base.m_name = "****_Bins";   //unique id, non-localizable (e.g. "MyCategory_MyCommand")

            try
            {
                //
                // TODO: change bitmap name if necessary
                //
                string bitmapResourceName = GetType().Name + ".bmp";
                base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
            }
        }

        #region Overridden Class Methods

        /// <summary>
        /// Occurs when this command is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (hook == null)
                return;

            m_application = hook as IApplication;

            //Disable if it is not ArcMap
            if (hook is IMxApplication)
                base.m_enabled = true;
            else
                base.m_enabled = false;

            // TODO:  Add other initialization code
        }

        private BinsForm binsForm;

        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            //get selected points
            IMxDocument mxdoc = ArcMap.Application.Document as IMxDocument;
            IList<int> selection = new List<int>();
            if (mxdoc.SelectedItem is IFeatureLayer2)
            {
                ILayer layer = mxdoc.SelectedLayer;
                IFeatureSelection featureSelection = layer as IFeatureSelection;
                var selectionSet = featureSelection.SelectionSet as ISelectionSet2;
                if (selectionSet != null)
                {
                    IEnumIDs enumIDs = selectionSet.IDs;
                    int id = enumIDs.Next();
                    while (id > 0)
                    {
                        selection.Add(id);
                        id = enumIDs.Next();
                    }
                }
            }
            else if (mxdoc.SelectedItem is IFeatureLayer)
            {
                ILayer layer = mxdoc.SelectedLayer;
                IFeatureSelection featureSelection = layer as IFeatureSelection;
                var selectionSet = featureSelection.SelectionSet as ISelectionSet;
                if (selectionSet != null)
                {
                    IEnumIDs enumIDs = selectionSet.IDs;
                    int id = enumIDs.Next();
                    while (id > 0)
                    {
                        selection.Add(id);
                        id = enumIDs.Next();
                    }
                }
            }
            else if (mxdoc.SelectedItem is ITable)
            {
                ITable table = mxdoc.SelectedItem as ITable;
                ITableSelection tableSelection = table as ITableSelection;
                var selectionSet = tableSelection.SelectionSet as ISelectionSet2;

                if (selectionSet != null)
                {
                    IEnumIDs enumIDs = selectionSet.IDs;
                    int id = enumIDs.Next();
                    while (id > 0)
                    {
                        selection.Add(id);
                        id = enumIDs.Next();
                    }
                }
            }

            if (selection.Count > 0)
            {
                this.binsForm = new BinsForm(selection.ToArray());
                this.binsForm.ShowDialog(new ArcMapWindow(ArcMap.Application));
            }
            else
            {
                MessageBox.Show("Before clicking this button select one or more points on the map and then select the feature layer.");
            }
        }



        #endregion
    }
}
3
  • are you looking the proper category in the Customize --> Commands dialog for the addin? By default, they go to "Add-In Controls" if not specified in the Config.ESRIAddinx file. You my try looking in there too and see where its being dropped..
    – ericoneal
    Commented Oct 5, 2015 at 17:52
  • 1
    @Easty , You don't have to import anything. simply double click the addin file and it get installed. There is probably something wrong with your Config.esriaddinx file. Please include the part that is related to this button in your question. Commented Oct 5, 2015 at 17:59
  • Thanks Guys and forgive my ignorance. I have added the Config.esriaddinx file. However I dont think the button is in there. I have a BaseCommand Dialog. I think that is where the button is attached. I will post this file. Other than this I only have a form that is opened when the button is clicked.
    – Easty
    Commented Oct 8, 2015 at 10:12

1 Answer 1

1

You need to add the toolbar(s) and button(s) to the config file, as shown below.

  <AddIn language="CLR" library="xxxx.dll" namespace="xxxx">
    <ArcMap>
      <Commands>
        <Button id="My_Button" class="MyButton" message="TODO" caption="TODO" tip="TODO" category="TODO" image="Images\xxxx.png" onDemand="false" />
      </Commands>
      <Toolbars>
        <Toolbar id="My_Toolbar" caption="TODO" showInitially="true">
          <Items>
            <Button refID="My_Button"/>
          </Items>
        </Toolbar>
      </Toolbars>
      <Extensions>
        [your extension info]
      </Extensions>
    </ArcMap>
  </AddIn>

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.