msoutlook.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

OL2000 'Illegal instruction' after adding menu to ActiveMenu

 
Post new topic   Reply to topic    msoutlook.org Forum Index -> Outlook Programs Add-Ins
Author Message
Georg-Hendrik



Joined: 01 Oct 2007
Posts: 3

PostPosted: Sun Sep 30, 2007 1:26 pm    Post subject: OL2000 'Illegal instruction' after adding menu to ActiveMenu Reply with quote

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);

CComQIPtr soOutlook;
CComPtr soExplorer;
CComPtr soBars;
CComPtr soActiveMenu;
CComPtr soMenuItems;
CComPtr 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;
}

Archived from group: microsoft>public>outlook>program_addins
Back to top
View user's profile Send private message
Dmitry Streblechenko



Joined: 12 Aug 2007
Posts: 220

PostPosted: Mon Oct 01, 2007 2:21 pm    Post subject: Re: OL2000 'Illegal instruction' after adding menu to Active Reply with quote

How do you subscribe to teh Click events? Or does the problem occur even if
you do not subscribe to the events at all?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Georg-Hendrik" wrote in message @microsoft.com...
> 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);
>
> CComQIPtr soOutlook;
> CComPtr soExplorer;
> CComPtr soBars;
> CComPtr soActiveMenu;
> CComPtr soMenuItems;
> CComPtr 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;
> }
Back to top
View user's profile Send private message
Georg-Hendrik



Joined: 01 Oct 2007
Posts: 3

PostPosted: Mon Oct 01, 2007 3:32 pm    Post subject: Re: OL2000 'Illegal instruction' after adding menu to Active Reply with quote

Thanks for the quick response.

The problem occurs even without subscribing to events. The original code
subscribed to Click events. Above attached code does not. In both cases, the
illegal instruction occurs at close of Outlook.

If it helps in narrowing the problem, calling soMyMenuItem->Delete()
immediatly after setting Caption and Tag, produces an access violation.

"Dmitry Streblechenko" wrote:

> How do you subscribe to teh Click events? Or does the problem occur even if
> you do not subscribe to the events at all?
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
> "Georg-Hendrik" wrote in message
> @microsoft.com...
> > 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);
> >
> > CComQIPtr soOutlook;
> > CComPtr soExplorer;
> > CComPtr soBars;
> > CComPtr soActiveMenu;
> > CComPtr soMenuItems;
> > CComPtr 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;
> > }
>
>
>
Back to top
View user's profile Send private message
Dmitry Streblechenko



Joined: 12 Aug 2007
Posts: 220

PostPosted: Tue Oct 02, 2007 6:30 pm    Post subject: Re: OL2000 'Illegal instruction' after adding menu to Active Reply with quote

Hmmm.. I don't know. Out of curiosity, why are you using
CommandBars.ActiveMenuBar? Have you tried to explicitly specify which
toolbar you want (CommandBars.Item["Toolbar Name"])?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Georg-Hendrik" wrote in message @microsoft.com...
> 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);
>
> CComQIPtr soOutlook;
> CComPtr soExplorer;
> CComPtr soBars;
> CComPtr soActiveMenu;
> CComPtr soMenuItems;
> CComPtr 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;
> }
Back to top
View user's profile Send private message
Georg-Hendrik



Joined: 01 Oct 2007
Posts: 3

PostPosted: Sun Oct 21, 2007 12:28 pm    Post subject: Re: OL2000 'Illegal instruction' after adding menu to Active Reply with quote

Thanks for the suggestion. I use CommandBars.ActiveMenuBar to be sure that I
am getting the commandbar that also holds the File, Edit, etc. menus.
As you suggested, I could also refer to commandbars.Item["Menu Bar"], but I
am not sure wheter, in all localised versions of Outlook, the name is also
"Menu Bar" . ActiveMenuBar always exists, and refers to the right bar.
I did try it, but the illegal instruction remains.
Is there perhaps something odd in my ComPtr's? Do you know of any working
ATL/C++ examples?

Sincerely,

Georg-Hendrik




"Dmitry Streblechenko" wrote:

> Hmmm.. I don't know. Out of curiosity, why are you using
> CommandBars.ActiveMenuBar? Have you tried to explicitly specify which
> toolbar you want (CommandBars.Item["Toolbar Name"])?
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
> "Georg-Hendrik" wrote in message
> @microsoft.com...
> > 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);
> >
> > CComQIPtr soOutlook;
> > CComPtr soExplorer;
> > CComPtr soBars;
> > CComPtr soActiveMenu;
> > CComPtr soMenuItems;
> > CComPtr 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;
> > }
>
>
>
Back to top
View user's profile Send private message
Dmitry Streblechenko



Joined: 12 Aug 2007
Posts: 220

PostPosted: Mon Oct 22, 2007 2:07 pm    Post subject: Re: OL2000 'Illegal instruction' after adding menu to Active Reply with quote

You migth want to look at the C++ samples at
http://www.outlookcode.com/article.aspx?ID=36

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Dmitry Streblechenko" wrote in message @TK2MSFTNGP04.phx.gbl...
> Hmmm.. I don't know. Out of curiosity, why are you using
> CommandBars.ActiveMenuBar? Have you tried to explicitly specify which
> toolbar you want (CommandBars.Item["Toolbar Name"])?
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
> "Georg-Hendrik" wrote in message
> @microsoft.com...
>> 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);
>>
>> CComQIPtr soOutlook;
>> CComPtr soExplorer;
>> CComPtr soBars;
>> CComPtr soActiveMenu;
>> CComPtr soMenuItems;
>> CComPtr 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;
>> }
>
>

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
New Inspector event in OL2000 when using Word as Editor Hi, We're working on an OL2000 COM addin that adds menu to New Mail window. Based on online literature, we should handle the New Inpsector event, however we found this event will not fire when using Word as email editor. We found the following KB which co

Context Menu [only] Hi there, Is it possible to only add a extra item in the context menu when the user right clicks on an email. For example, when the user right click on a folder, not to show the extra item added to the context. If so, is it possible to advise me in the ri

Add a custom menu to a context menu Im working on an COM addin for Outlook and I would like to be able to add my very own menu when someone right click on an outlook mailitem... All I found so far are exemples on how to create custom commandbars and some popup menu only usable on forms.. An

Outlook Express - Illegal Operation message I can not click on emails without getting the message that MSIMN caused an invalid page fault in module MSOERT2.DLL. Tried downloading IE 6.0 and the new Outlook Express shows me the lines but not the text of emails. Does anyone have any i

Right Click Menu How can I add a macro to my right click popup menu when an item is selected in the Inbox? Thanks, Craig
Post new topic   Reply to topic    msoutlook.org Forum Index -> Outlook Programs Add-Ins All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group