views:

56

answers:

3

I have an application that has two distinct parts, one operation that process data and adds it to a database and a second operation that retrieves the data and makes a report. Is there a way to tell the debugger to start at the second operation of the application? Previously I've commented out what I didn't want to run and worked around my issue in that way. Is there a better way? Thanks.

+1  A: 

I assume you have two methods in one piece of code, such as a Main method?

Main() 
{
   DoOperationOne();
   DoOperationTwo();
}

An easy way to skip over one is to read about Set the Next Statement.

RichardOD
this looks promising. Thank you.
jim
@Jim- you might want to make this process less painful by looking at this- http://stackoverflow.com/questions/455290/can-i-have-a-hit-point-in-visualstudio-that-skips-lines
RichardOD
+2  A: 

Breakpoints? E.g. assuming the app structure is

DoTheFirstPart()
DoTheSecondPart()

put a breakpoint on the second part and run in the debugger, and then once you hit the breakpoint, do whatever other debugging you need (add more breakpoints, turn on catch-all-exceptions, etc.) This will still run the first part - it's unclear to me if that's what you want or not.

(Question is a little vague, it's unclear what strategies you know/tried and what your goal is.)

Brian
for the confusion on the question, I really doubt that his application is that simple and structured :P
balexandre
+1  A: 

If your language has an equivilent to #ifdef you could use that and a runtime parameter to avoid repeatedly commenting out code.

Edit: This assumes you don't want the first operation to run for whatever reason, question's a bit vague.

Mark
I _think_ the OP is ideally trying not to modify the original program (e.g. "is there a better way" == "I have this great tool called Visual Studio, but I am unsure what feature to use to do X"). But I am not 100% sure. In any case, if you modify the original program, the question isn't too interesting.
Brian
I'm not sure why you got downvoted since the user did actually say he was currently commenting out the code. Rather than use comments, a much better way would be to use a #if _DEBUG as you suggested. Have one vote from me ;)
jussij
I would also concur for this being a correct answer. If you really want to use the debug features of Visual Studio and only want to focus on one area, this would certainly be a good way to skip a set of events your not interested or setup a set of test data automatically and jump to the section of code you are interested in. +1 from me too. Not sure why this got down voted ;-)
Sebastian Gray
ahh...Conditional Methods...what i don't know could fill a book. This is great. Thanks fellas
jim