Enable command when extension is activated

Discussion created by cpicciri on Jun 10, 2010
Latest reply on Jun 15, 2010 by cpicciri
Hi everyone,

I am working on my first extension and have run into a problem. I am sure this problem is something simple, but I have been fighting with this for 2 days now and have looked at every example on the forums to do with extensions plus all the sample ESRI code I could find with no luck.

My extension works in conjuction with a custom toolbar. I have placed the code below in every command on the toolbar to disable it if the extension is turned off and this works fine. If the user turns on the extension first, then the toolbar, everything works fine but if the user turns on the toolbar first, then the extension, all of commands stay disabled.

What I think I need to do is activate the commands from the extension enabled code but can't figure out how to do this. All of my commands were created using the BaseCommand templates in C#.


        public override void OnCreate(object hook)
            if (hook == null)

            m_application = hook as IApplication;

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

            //Disable if RegGSS extension not turned on.
            UID pUID = new UIDClass();
            pUID.Value = "RegGSS.Extension";
            IExtensionConfig pExtension = m_application.FindExtensionByCLSID(pUID) as IExtensionConfig;

            if (pExtension == null)

            if (pExtension.State == esriExtensionState.esriESEnabled)
                base.m_enabled = true;
                base.m_enabled = false;