locked
VB 2010 does't return error in the development RRS feed

  • Question

  • Dear all, 

    Would like to find out, why some of my windows form application doesn't return error during the development in visual studion.

    For ex, i have a pcs of code in a winform load event. The code actually got error. Instead of point which line of source got problem, the VS just show the form directly. 

    Not sure any option did i disable it or 

    Wednesday, September 23, 2015 2:44 AM

Answers

  • Would like to find out, why some of my windows form application doesn't return error during the development in visual studion.

    The best solution is to not put code in the form load event. Or, only include code that does simple initialisation of variables.

    If you must put code in that event, then to debug it you will need to move the code out into a SUB, add a temporary button to the form, and call the sub from that button.  When you have fixed things so that it cannot error, call the sub from the form load event and remove the temporary button.

    If the error occurs because the code is in the form load event (for instance, the code is referencing a control that is not fully initialised) then you have to reconsider your design.

    For example:

    http://blogs.msdn.com/b/debugger/archive/2010/05/12/visual-studio-debugger-fails-to-catch-unhandled-exception-for-a-windows-form-or-wpf-application.aspx

    • Proposed as answer by Blackwood Wednesday, September 23, 2015 11:46 AM
    • Marked as answer by Youjun Tang Wednesday, October 7, 2015 7:48 AM
    Wednesday, September 23, 2015 6:49 AM

All replies

  • Would like to find out, why some of my windows form application doesn't return error during the development in visual studion.

    The best solution is to not put code in the form load event. Or, only include code that does simple initialisation of variables.

    If you must put code in that event, then to debug it you will need to move the code out into a SUB, add a temporary button to the form, and call the sub from that button.  When you have fixed things so that it cannot error, call the sub from the form load event and remove the temporary button.

    If the error occurs because the code is in the form load event (for instance, the code is referencing a control that is not fully initialised) then you have to reconsider your design.

    For example:

    http://blogs.msdn.com/b/debugger/archive/2010/05/12/visual-studio-debugger-fails-to-catch-unhandled-exception-for-a-windows-form-or-wpf-application.aspx

    • Proposed as answer by Blackwood Wednesday, September 23, 2015 11:46 AM
    • Marked as answer by Youjun Tang Wednesday, October 7, 2015 7:48 AM
    Wednesday, September 23, 2015 6:49 AM
  • Another option is to select from the IDE debug menu, exceptions then for "Common Language RunTime Exceptions" check it, run the project again. Even if there is a try/catch the debugger will expose any exceptions to you if there are any in form load or other events.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my webpage under my profile but do not reply to forum questions.
    Microsoft Developer tools
    Developer’s Guide to Windows 10 video series

    Wednesday, September 23, 2015 9:45 AM