Can I get an access point in VisualStudio that skips lines?

I often come across a situation where I want to disable some code during debugging without actually changing the code.

As a result, I get a breakpoint (usually conditional), and then when the breakpoint fires, I execute the Set Next command. This can be very time consuming when the code is reached many times, so I created a macro:

Sub Skip3Lines() DTE.ActiveDocument.Selection.LineDown(False, 3) DTE.Debugger.SetNextStatement() End Sub 

Then I changed my breakpoint as a hit point ( right-click -> When Hit... ) and told her to execute this macro.

Visual Studio was too happy to spit out the following dialog box:

---------------------------
Error
---------------------------
A macro called a debugger action which is not allowed while responding to an event or while being run because a breakpoint was hit.
---------------------------
OK
---------------------------

Does anyone know how to get around this?

+6
debugging visual-studio
source share
4 answers

DTE.ExecuteCommand ("Debug.SetNextStatement")

+8
source share

It doesn't turn around changing a bit of code, but what about a local logical? Wrap the code that you want to conditionally skip with the if statement. By default, this value is true and reinitialize it each time. Then, assuming that you can write a macro that changes this value to false, you can enable / disable the hit point on demand.

Never done this before, so you can tell me that macros don't work like that. Usually I just use edit-and-continue, commenting on the code I want to skip. Of course, this does not work if there is a lambda or anonymous type / method in the code.

0
source share

Perhaps you can determine if it is in debug mode, and then use the if statement to prevent the code from starting, here is more information

http://weblogs.asp.net/jkey/archive/2003/11/23/39383.aspx

-one
source share

Could you use compiler conditions in this case?

 #IF Config = "Debug" Then ' do my debug code here #Else ' do my normal coding here #End if 
-one
source share

All Articles