Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable Try...Catch while testing

Status
Not open for further replies.

Andrzejek

Programmer
Jan 10, 2006
8,509
US

Very basic question:

If I have a piece of code with Try...Catch :
Code:
Try[green]
    'Some code goes here[/green]
Catch ex As Exception
    MsgBox(ex.Message)
Finally

End Try
During testing I would like the code to stop on the trouble line of code in [tt]Try[/tt] part and not go to [tt]Catch ex As Exception[/tt] part.

Is that possible?


Have fun.

---- Andy
 
Code:
Try
    'Some code goes here
#If Not Debug Then
Catch ex As Exception
    MsgBox(ex.Message)
#End If
Finally

End Try
 
If you are using Visual Studio, you can change this behavior globally by breaking when the exception is thrown. The way you set this has changed over time, but is possible from at least VS 2003.

In VS 2008 you would want to select "Debug | Exceptions..." from the file menu. If you don't see it on the list you can use "CTRL + ALT + E" to pull it up. Now just click on the checkbox next to "Common Language Runtime Exceptions" in the "Thrown" column and click on OK to apply your change.

This change will be in effect regardless of the configuration you are using (Debug, Release, etc) until you change the value back.

Scott Travis
Enterprise Expressions, LLC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top