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