Visual Studio Development Bookmark and Share   
 index > Visual Studio Tools for Office > 3:55 AM - I'm at a complete loss why my OL2003 add-in is crashing - please help
 

3:55 AM - I'm at a complete loss why my OL2003 add-in is crashing - please help

Hi - this is my first post. I've been using VSTO for about 5 days, this is my first office add-in project.

It's pretty simple at this stage, I've added some CommandBarButtons to the UI and context menu. Everything was working fine until I tried to display a Form in the Click handler of one of my buttons.

Here is the code:
<code>
void button_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault)
{
//return;
try
{
if (_explorer.Selection.Count > 0 && _explorer.Selection[1] is Outlook.MailItem)
{
Outlook.MailItem mailItem = _explorer.Selection[1] as Outlook.MailItem;
if (mailItem.Attachments.Count > 0 && mailItem.Attachments[1].FileName.Contains(".pdf"))
{
AcceptNewLeadView view = new AcceptNewLeadView();
view.ShowDialog();
}
}
}
catch(Exception e)
{
Trace.TraceError(e.Message);
MessageBox.Show(e.Message);
}
}
</code>

I'm getting totally random crashes with no exceptions being thrown (I have ALL my code wrapped in try/catch blocks).

Steps to reproduce:
right click on random MailItems and click on my context menu item.
Do this enough times and eventually the menu item is gone and the add-in appears to have quietly died, no errors, no exceptions... just poof! - gone.

If I comment out the following lines:
<code>
AcceptNewLeadView view = new AcceptNewLeadView();
view.ShowDialog();
</code>

I can right click and and choose my context menu item all day long, no problems, everything works.

The Form I'm instantiating and showing is empty. I just right clicked in my solution and created a new one.

I've verified 20-30 times now that commenting out those 2 lines makes the problem go away.

I don't understand what is happening, like I said, there are no errors or exceptions, it just dies.

Please, please can someone help me with this? I'm going nuts!

Thanks for reading, I look forwar (hopefully) to reading your responses after I get a couple hours of sleep :0(

-Steve
sklett  Friday, May 25, 2007 11:01 AM

Hi Steve -

Without being able to see how your eventing is hooked up, we can't do much more to help. The exception you're seeing would be a start (assuming there is an exception).

2 -- perfect compromise. Let's see a simple repro, and hopefully we can isolate the issue.

Thanks,

Andrew

Andrew Cherry [MSFT]2  Saturday, June 30, 2007 2:41 AM
Me again.

I've got 2 questions:

1) Are there any other additional techniques or tools that I can use to find out what is crashing my add-in? The fact that it silently dies is making it IMPOSSIBLE for me to know what is causing the problem. I have since determined that creating and showing the form isn't the only cause of the crash, it seemed to just cause it to happen more frequently. I've noticed that changing to a different folder and right clicking an item will also cause the add-in to go away.

2) If I clean up my add-in code to a very simple example that is exhibiting the problem, would you be willing to take a look (not install it, just review the code on the forum) and see if I'm doing something incorrect? The fact that I'm not getting any exceptions and for the most part the add-in does what I want makes me think I'm doing everything OK, but maybe there is something subtle that is causing instability?

Thanks for reading, have a great weekend.
-Steve
sklett  Friday, May 25, 2007 7:28 PM

Hi Steve -

Without being able to see how your eventing is hooked up, we can't do much more to help. The exception you're seeing would be a start (assuming there is an exception).

2 -- perfect compromise. Let's see a simple repro, and hopefully we can isolate the issue.

Thanks,

Andrew

Andrew Cherry [MSFT]2  Saturday, June 30, 2007 2:41 AM

You can use google to search for other answers

Custom Search

More Threads

• How do I get all the Named Range information using Microsoft.Office.Interop.Excel.Worksheet object
• Orphan Winword.exe with PIA
• Application idea - will this work ? need suggestions for using ms word forms within application
• Outlook appointment items don't seem to correctly report dates or calculate dates
• Outlook add-in security for deployment
• Drag and Drop from Winforms to Excel
• granting fulltrust to assemblies
• Drag and Drop from Actions Pane to Document
• Why do I have multiple instances of TrinStgClass when cut-n-pasting VSTO docs?
• Programmatically turning on Smart Tags in Word?