[ACCEPTED]-How to temporarily deactivate all try / catch blocks?-visual-studio

Accepted answer
Score: 42

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.

enter image description here

Score: 16

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

Score: 3

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:

  Imports CatchAtReleaseException = System.NeverOccurException
  Imports CatchAtReleaseException = System.Exception
#End If


  '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()
    Catch ex As CatchAtReleaseException
    End Try
  End Sub

Have fun with it, Greetings, Ted

Score: 1

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.

Score: 0

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