Do you have ideas for a workaround for this Known bug in Visual Studio 2010's addIn model ?

Posted by Jesper on Stack Overflow See other posts from Stack Overflow or by Jesper
Published on 2010-06-04T20:46:59Z Indexed on 2010/06/06 16:12 UTC
Read the original article Hit count: 573

When developing AddIns for Visual Studio 2010 the following line fails:

CommandBarEvents handler = (EnvDTE.CommandBarEvents)m_VSStudio.DTE.Events.get_CommandBarEvents(popup);

Update: Forgot to tell that m_VSStudio is of the type DTE2

Where popup is of the type CommandBarPopup (for the type CommandBarControl it works though)

The line fails with this Exception:

System.Runtime.InteropServices.COMException (0x80020003): Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))

The exact same line worked in Visual Studio 2008.

The purpose of the line is to get a handler which handles clickevents, when one clicks the Popup.

After som searching I found this link: http://connect.microsoft.com/VisualStudio/feedback/details/524335/events-get-commandbarevents-exception-on-submenus-reproducible-bug-addin

Which basicly states that it is a known bug, which will not be fixed, because there is a workaround. But unfortunately it does not state the workaround :(

I would be extremely pleased if anybody has a great idea for a workaround ?

The reason why I want to listen to the click events is because I want to show or hide the submenuitems (CommandBarControl) given some condition, when one clicks a menu (CommandBarPopup).

So a workaround that uses something else than the click event would also be appreciated.

© Stack Overflow or respective owner

Related posts about c#

Related posts about visual-studio-2010