Extension for ArcMap - Problem adding customized menu

Discussion created by stikut on Oct 15, 2012

I have a COM-registered extension for ArcMap which adds a new menu to Table Of Contents, and during its NewDocument event I'm creating a custom meny (in runtime).

Here is the code:

void ApplicationExtension1_NewDocument()
UID objMainMenuId = new UIDClass();
            objMainMenuId.Value = "{1E739F59-E45F-11D1-9496-080009EEBECB}";
            ICommandBar objMainMenuBar = (ICommandBar)m_objApplication.Document.CommandBars.Find(objMainMenuId, false, false);

            UID objId = new UIDClass();
            object objIndex = 0;

            if (objMainMenuBar != null)
                objId.Value = typeof(CCMyMenu).FullName;
                objMainMenuBar.Add(objId, ref objIndex);

CCMyMenu implements IMenuDef, IRootLevelMenu

Now this works perfectly in a small testing application but refuses to work in the real system (exactly the same code)

Using an Add-In instead of the extension is currently not an option.

Any help would be greatly appreciated.