none
How does one debug? RRS feed

  • Question

  • I just got Visual Studio 2008 with VSTO.  I've created a new Word Addin Project (2007).  In playing around, I've noticed that some exceptions don't seem to come back to Visual Studio ... Word seems to Eat them.

    So, I tried to even see if the code was being run by putting some alerts at each of the different events I intend to target,

    •     ThisAddIn_Startup
    •     ThisAddIn_Shutdown
    •     Application_DocumentOpen
    •     Application_NewDocument
    •     Application_WindowActivate

    With just msgbox in each of the subs, it seems to work as expected.  But when I add in "Throw New Exception", VSTO doesn't break as expected and the messagebox is not shown (which, I suppose, is to be expected when the sub is in error)

    The exception does seem to come back and break on  ThisAddIn_Startup and ThisAddIn_Shutdown -- but if any of the other events throw an exception, nothing seems to happen and I'm left scratching my head wondering why code isn't being run.

    In the Immediate Window, I see a series of  " A first chance exception of type 'System.Exception' occurred in MyAddin.DLL " lines which seem to correspond to exceptions  ....  How does one debug these things?

    Thanks!


    Wednesday, May 25, 2011 5:04 AM

Answers

  • You need to put all your code in Try...Catch blocks in order to "bubble up" all errors back to your .NET project. Try...Catch should keep Word from "eating" things.
    Cindy Meister, VSTO/Word MVP
    • Marked as answer by tswaters Friday, May 27, 2011 11:44 PM
    Wednesday, May 25, 2011 9:11 AM
    Moderator

All replies

  • You need to put all your code in Try...Catch blocks in order to "bubble up" all errors back to your .NET project. Try...Catch should keep Word from "eating" things.
    Cindy Meister, VSTO/Word MVP
    • Marked as answer by tswaters Friday, May 27, 2011 11:44 PM
    Wednesday, May 25, 2011 9:11 AM
    Moderator
  • Thanks Cindy, most helpful.

    Friday, May 27, 2011 11:44 PM