[ACCEPTED]-How to temporarily deactivate all try / catch blocks?-visual-studio
To catch exceptions the moment they're thrown 4 ("first-chance exceptions" in 3 Win32 parlance):
in VS2008: go to Debug, Exceptions...
by VS2015: this 2 has been moved to Debug > Windows > Exception Settings
Then check the box Thrown for 1 Common Language Runtime Exceptions.
There is no way to deactivate try/catch 6 blocks.
However, for debug purposes, if you 5 want to break as soon as a particular type 4 of exception is thrown, you can get Visual 3 Studio to do that (Debug -> Exceptions; select 2 the exception type you're interested in 1 and check the "Thrown" box).
Thought about this today and found an other 5 solution. The advantage of this is that 4 the IDE will stop at the exact point of 3 the occuring exception.
Somewhere globaly 2 defined:
Namespace Global.System
Public Class NeverOccurException
Inherits Exception
End Class
End Namespace
At the beginning of each source 1 code file:
#If DEBUG
Imports CatchAtReleaseException = System.NeverOccurException
#Else
Imports CatchAtReleaseException = System.Exception
#End If
Usage:
'Compiled in DEBUG-Mode the TryCatch is "disabled", because the
'the ALIAS CatchAtReleaseException is set to "NeverOccurException"
'Compiled as RELEASE the TryCatch is "enabled", because the ALIAS
'is set to the regular "System.Exception"
Public Sub SampleSub()
Try
'...
Catch ex As CatchAtReleaseException
End Try
End Sub
Have fun with it, Greetings, Ted
If you want to do in the IDE, Debug -> Exceptions 3 is the dialog where you can ask the IDE 2 to break when a specific/category/all exceptions 1 are thrown.
You can change the way Visual Studio breaks 9 when an exception occurs. By default, it 8 breaks on unhandled exceptions. If you go 7 to menu Debug > Exceptions, you can uncheck 6 Common Language Runtime Exceptions and make 5 other changes in the IDE's behavior when 4 exceptions occur. For example, you can have 3 it break on only one kind of exception; there's 2 a long list there.
I have done this on rare 1 occasions when trying to debug.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.