A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

AddIn crashes Outlook 2007



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 30th 06, 03:09 PM posted to microsoft.public.outlook.program_addins
Charles Sinclair
external usenet poster
 
Posts: 6
Default AddIn crashes Outlook 2007

I have an AddIn that works fine on Outlook 2000, 2002 and 2003, but crashes
Outlook 2007 Beta 2. I am using VC++ 6 with #import. The AddIn places a
single toolbar with a single button on an Inspector window. With Outlook
2007, it randomly crashes when the Inspector is closed. It appears to be
something to do with CommandButton events. If I remove the call to
DispEventAdvise for the button, the crash goes away. The Open/Close Inspector
event handling appears to work fine.

Perhaps related is that FindControl seems very unreliable. Sometimes it
works, sometimes it doesn't. I have tried manually enumerating the controls
on my toolbar, but this fails too, because CommandBarControlsPtr-Count
returns 0, even though I can see the button on the Inspector toolbar myself.
What is also odd is that this unreliability seems confined to the AddIn. The
same code as a separate EXE work OK.

Are any of these known Beta 2 issues? Or does anyone have any suggestions?

Ads
  #2  
Old May 30th 06, 08:03 PM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default AddIn crashes Outlook 2007

Do you unadvise your event sinks and release all the COM objects related to
the inspector (inspector, command bars, buttons, etc) when inspector closes?

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

"Charles Sinclair" wrote in
message ...
I have an AddIn that works fine on Outlook 2000, 2002 and 2003, but crashes
Outlook 2007 Beta 2. I am using VC++ 6 with #import. The AddIn places a
single toolbar with a single button on an Inspector window. With Outlook
2007, it randomly crashes when the Inspector is closed. It appears to be
something to do with CommandButton events. If I remove the call to
DispEventAdvise for the button, the crash goes away. The Open/Close
Inspector
event handling appears to work fine.

Perhaps related is that FindControl seems very unreliable. Sometimes it
works, sometimes it doesn't. I have tried manually enumerating the
controls
on my toolbar, but this fails too, because CommandBarControlsPtr-Count
returns 0, even though I can see the button on the Inspector toolbar
myself.
What is also odd is that this unreliability seems confined to the AddIn.
The
same code as a separate EXE work OK.

Are any of these known Beta 2 issues? Or does anyone have any suggestions?



  #3  
Old May 31st 06, 02:22 PM posted to microsoft.public.outlook.program_addins
Charles Sinclair
external usenet poster
 
Posts: 6
Default AddIn crashes Outlook 2007

Thank you for your reply.

Do you unadvise your event sinks and release all the COM objects related
to the inspector

Absolutely. I have double checked this and checked again now. The AddIn
works perfectly under Outlook 2003 and earlier. Those versions of Outlook
also exit cleanly, which perhaps suggests that no outstanding references to
Outlook COM objects are left open.

Regarding the FindControl issue, which I feel is related (because the common
theme seems to be custom toolbars), I said earlier that FindControl in the
AddIn was unreliable (sometime it finds the control and sometime it doesn't),
while identical code in a standalone EXE always found the control. I now
realize that this is due to a timing issue. The code that fails in the AddIn
gets executed during the OnNewInspector event handler. During this time it
seems that custom toolbar controls may or may not be available. Also, when I
fetch the correct toolbar to enumerate the controls myself, the Controls
count is sometimes zero, even though the control exists.

When the toolbar button does exist but FindControl returns NULL, then the
Add method of the Controls collection will always return an "invalid index"
error (which makes no sense to me).

Any suggestions would be appreciated. My feeling is that this is likely to
be an Outlook 2007 Beta 2 issue, since a) none of these issues happen with
Outlook 2003 and earlier and b) I would not expect a bug in an AddIn to crash
Outlook, given that all my event handlers are in try/catch blocks.

Office::CommandBarPtr cmdBar;
Office::CommandBarControlPtr button;
button = cmdBar-FindControl(vtMissing, 1L, tag); // This sometimes does not
work
if (button == NULL)
{
_variant_t vButtonType = (long) Office::msoControlButton;
button = cmdBar-Controls-Add(vButtonType); // This sometimes returns
"invalid index"
}

  #4  
Old May 31st 06, 04:16 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default AddIn crashes Outlook 2007

Even with earlier versions of Outlook you might get that condition unless
you wait until the first Inspector.Activate event fires. I've had problems
with that, especially with WordMail in email Inspectors, even with Outlook
2003.

I use the first Activate event, create my buttons, use FindControl, etc.
then and set a flag that I've already done that so future activates don't
follow the same code path.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Charles Sinclair" wrote in
message ...
Thank you for your reply.

Do you unadvise your event sinks and release all the COM objects related
to the inspector

Absolutely. I have double checked this and checked again now. The AddIn
works perfectly under Outlook 2003 and earlier. Those versions of Outlook
also exit cleanly, which perhaps suggests that no outstanding references
to
Outlook COM objects are left open.

Regarding the FindControl issue, which I feel is related (because the
common
theme seems to be custom toolbars), I said earlier that FindControl in the
AddIn was unreliable (sometime it finds the control and sometime it
doesn't),
while identical code in a standalone EXE always found the control. I now
realize that this is due to a timing issue. The code that fails in the
AddIn
gets executed during the OnNewInspector event handler. During this time it
seems that custom toolbar controls may or may not be available. Also, when
I
fetch the correct toolbar to enumerate the controls myself, the Controls
count is sometimes zero, even though the control exists.

When the toolbar button does exist but FindControl returns NULL, then the
Add method of the Controls collection will always return an "invalid
index"
error (which makes no sense to me).

Any suggestions would be appreciated. My feeling is that this is likely to
be an Outlook 2007 Beta 2 issue, since a) none of these issues happen with
Outlook 2003 and earlier and b) I would not expect a bug in an AddIn to
crash
Outlook, given that all my event handlers are in try/catch blocks.

Office::CommandBarPtr cmdBar;
Office::CommandBarControlPtr button;
button = cmdBar-FindControl(vtMissing, 1L, tag); // This sometimes does
not
work
if (button == NULL)
{
_variant_t vButtonType = (long) Office::msoControlButton;
button = cmdBar-Controls-Add(vButtonType); // This sometimes returns
"invalid index"
}


  #5  
Old June 1st 06, 06:43 PM posted to microsoft.public.outlook.program_addins
Charles Sinclair
external usenet poster
 
Posts: 6
Default AddIn crashes Outlook 2007

Many thanks for your input. I'll certainly give this a try.

"Ken Slovak - [MVP - Outlook]" wrote:

Even with earlier versions of Outlook you might get that condition unless
you wait until the first Inspector.Activate event fires. I've had problems
with that, especially with WordMail in email Inspectors, even with Outlook
2003.

I use the first Activate event, create my buttons, use FindControl, etc.
then and set a flag that I've already done that so future activates don't
follow the same code path.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Charles Sinclair" wrote in
message ...
Thank you for your reply.

Do you unadvise your event sinks and release all the COM objects related
to the inspector

Absolutely. I have double checked this and checked again now. The AddIn
works perfectly under Outlook 2003 and earlier. Those versions of Outlook
also exit cleanly, which perhaps suggests that no outstanding references
to
Outlook COM objects are left open.

Regarding the FindControl issue, which I feel is related (because the
common
theme seems to be custom toolbars), I said earlier that FindControl in the
AddIn was unreliable (sometime it finds the control and sometime it
doesn't),
while identical code in a standalone EXE always found the control. I now
realize that this is due to a timing issue. The code that fails in the
AddIn
gets executed during the OnNewInspector event handler. During this time it
seems that custom toolbar controls may or may not be available. Also, when
I
fetch the correct toolbar to enumerate the controls myself, the Controls
count is sometimes zero, even though the control exists.

When the toolbar button does exist but FindControl returns NULL, then the
Add method of the Controls collection will always return an "invalid
index"
error (which makes no sense to me).

Any suggestions would be appreciated. My feeling is that this is likely to
be an Outlook 2007 Beta 2 issue, since a) none of these issues happen with
Outlook 2003 and earlier and b) I would not expect a bug in an AddIn to
crash
Outlook, given that all my event handlers are in try/catch blocks.

Office::CommandBarPtr cmdBar;
Office::CommandBarControlPtr button;
button = cmdBar-FindControl(vtMissing, 1L, tag); // This sometimes does
not
work
if (button == NULL)
{
_variant_t vButtonType = (long) Office::msoControlButton;
button = cmdBar-Controls-Add(vButtonType); // This sometimes returns
"invalid index"
}



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook Express Addin Joshua Ellul Add-ins for Outlook 0 April 30th 06 11:00 PM
A different problem with Outlook Addin Ram Add-ins for Outlook 1 April 24th 06 02:31 PM
Outlook Crashes on Startup asdf Outlook - General Queries 2 April 1st 06 04:43 PM
Outlook crashes on import [email protected] Outlook - Using Contacts 4 March 13th 06 08:12 PM
Outlook addin help Melbin Outlook - Using Forms 0 January 24th 06 12:12 PM


All times are GMT +1. The time now is 01:22 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.