View Single Post
  #1  
Old September 30th 07, 05:26 PM posted to microsoft.public.outlook.program_addins
Georg-Hendrik
external usenet poster
 
Posts: 3
Default OL2000 'Illegal instruction' after adding menu to ActiveMenubar

This one really puzzles me.

I'm developing an Outlook COM Add-in, C++/ATL, which is to work under
Outlook 2k - 2k7. I've simplified the code and isolated the problem in a
default VS2005 Extensibility project, of which below you can find the code
from the OnConnection method.

The project compiles fine and shows no issues under Outlook 2007.
Also in Outlook 2000, everything works fine until Close is pressed.
Then it faults with 'exception at 0x030f0db6 in OUTLOOK.EXE: 0xC000001D:
Illegal Instruction.'

It only faults if I press buttons on the toolbar (e.g. Calendar, Contacts)
before exiting.

The problem seems to involve use of the ActiveMenubar - if I add a new
CommandBar and add the ControlPopup to that, the problem does not occur.

Who can help?

Sincere regards,

Georg-Hendrik


Attachement 1: OnConnection Method (in standard VS2005 Extensibility project)

STDMETHODIMP CConnect::OnConnection(...)
{
// Default code
pApplication-QueryInterface(__uuidof(IDispatch), (LPVOID*)&m_pApplication);
pAddInInst-QueryInterface(__uuidof(IDispatch), (LPVOID*)&m_pAddInInstance);

// Isolated problem code starts here
::MessageBox(NULL, _T("Connection"), NULL, 0);

CComQIPtrOutlook::_Application soOutlook;
CComPtrOutlook::_Explorer soExplorer;
CComPtrOffice::_CommandBars soBars;
CComPtrOffice::CommandBar soActiveMenu;
CComPtrOffice::CommandBarControls soMenuItems;
CComPtrOffice::CommandBarControl soMyMenuItem;

try
{
// Get to the active Outlook menu bar controls...
soOutlook = pApplication;
soExplorer = soOutlook-ActiveExplorer();
soBars = soExplorer-GetCommandBars();
soActiveMenu = soBars-ActiveMenuBar;
soMenuItems = soActiveMenu-GetControls();

// ... and add an empty pop-up menu.
soMyMenuItem = soMenuItems-Add(msoControlPopup, vtMissing, vtMissing,
vtMissing, VARIANT_TRUE);

soMyMenuItem-Caption = _T("MyMenuItem");
soMyMenuItem-Tag = _T("my.menuitem");
}

catch (...)
{
::MessageBox(NULL, _T("BFE"), NULL, 0);
}

// The error shows regardless of the following
// few lines of code; Setting the CComPtr s to
// NULL did work for five minutes (literally...)

soMyMenuItem = NULL;
soMenuItems = NULL;
soActiveMenu = NULL;
soBars = NULL;
soExplorer = NULL;

return S_OK;
}
Ads