Greetings.
I recently inherited an addin designed for VS2003.
I was asked to get it running and update it in VS2005.
It is written in native C++.
I made sure to update the .rgs file so that it points to 8.0 instead of 7.1
. The addin compiles and displays in the Addin Manager. When enabled, it adds
in item to the Tools menu. Next, it is supposed to add a submenu to that.
This is where it fails.
I have tracked down the exact point at which it fails. Below is the relavent
code.
// Private field
POfcCommandBarControl m_pControlXMPopup;
// Inside a method to setup menu
POfcCommandBar pToolsBar;
POfcCommandBarControls pControls;
POfcCommandBars pBars;
// Get command bar interface
m_pDTE->get_CommandBars( (EnvDTE::_CommandBars**) &pBars);
// Acquire Tools menubar
pBars->get_Item( CComVariant( "Tools" ), &pToolsBar);
// Get controls
pToolsBar->get_Controls( &pControls);
// Create popup menu
pControls->Add( CComVariant( Office::msoControlPopup ), CComVariant(1),
CComVariant(), CComVariant(1), varFalse, &m_pControlXMPopup);
// !!! This fails in VS2005 !!!
// returns NULL
// QueryInterface returns E_NOINTERFACE
POfcQICCommandBarPopup pPopup = m_pControlXMPopup;
m_pControlXMPopup is non-null. The typedef resolves to
ATL::CComPtrBase<Office::CommandBarControl>. The assignment results in an
automatic call to CComQIPtr(__in_opt IUnknown* lp) {...} in atlcomcli.h. This
method calls QueryInterface and results in E_NOINTERFACE.
I need the POfcQICCommandBarPopup to call get_CommandBar() and then add new
items to it.
The code worked fine in VS2003, which is a little puzzling.
What is wrong here?
Are there any alternatives or workarounds?
Regards.
Carlos J. Quintero [VB MVP] - 08 Aug 2006 12:23 GMT
Be aware that VS.NET 2003 add-ins and VS 2005 addins use different Office
DLLs to provide the command bars. Create a simple add-in with the wizard in
each environment to know about them.

Signature
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
> Greetings.
> I recently inherited an addin designed for VS2003.
[quoted text clipped - 50 lines]
>
> Regards.
Dono - 08 Aug 2006 14:56 GMT
> Be aware that VS.NET 2003 add-ins and VS 2005 addins use different Office
> DLLs to provide the command bars. Create a simple add-in with the wizard in
> each environment to know about them.
Thanks.
I have since resolved this issue.
The following page, while difficult to find, was quite useful:
http://msdn2.microsoft.com/en-us/library/ms165634.aspx
Regards