37

Is there an option to edit the code when debugging in a breakpoint in Visual Studio. When I stop, all files seems locked for editing.

Is there a way to change this behaviour? It is possible in Eclipse

EDIT: after trying all suggested below (including move it to debug from release) now it is telling me I don't have the correct ms-office version and debug cannot start in debug mode. However, in release mode it was working. I am trying to debug an outlook add-in.

2
  • What happens when you try to change some piece of code in a file when debugging? Commented Apr 15, 2011 at 6:09
  • Similar question: stackoverflow.com/q/1088376/758666 Commented Oct 29, 2013 at 2:19

4 Answers 4

43

Yes, it's called "Edit and Continue", in Tools | Options under Debugging. Note that it's not compatible with IntelliTrace, so you have to disable that if you're using it. (Thank you Anton Semenov for that info.)

Edit: If you're using a really old version (the original VS.Net, as opposed to VS.Net 2005 or later), it was pretty fiddly about this (or didn't have it, I can't quite recall; I just remember being frustrated). But if you're using VS.Net 2005 or later, in my experience, it's enabled by default and works very well. When execution is paused (and you said you'd hit a breakpoint, so...), you can make quite a variety of changes and the environment will happily compile them and continue. Make sure all of the projects you want to debug are in the solution.

Sign up to request clarification or add additional context in comments.

6 Comments

Is this feature disabled by default?
@Oscar: Not in my experience, with VS.Net 2005 or VS.Net 2008.
Please note, that you cannot use edit and continue if you have Intelli trace enabled (VS2010)
@ohadshai: Sorry, don't know, I've never used the office add-in.
@AntonSemenov your comment is absolutely vital. Disabling Intellitrace made it work for me.
|
7

In general, it is possible, but you have to make sure you are compiling your project to x86 platform.

For this, right click on the project name in the Solution Explorer, go to Build and set the Platform Target to x86.

Edit:
Of course, in order to be able to edit a file, the execution need to be paused (in a breakpoint, for example)

Comments

5

yes you can update code in debug mode. Set the break point to the point which u want to edit . When the execution comes to this point then edit your code then press f5. It will take the changes.

Comments

0

win7

Yes, it's called "Edit and Continue", in Tools | Options under Debugging. Note that it's not compatible with IntelliTrace


win10 can turn on IntelliTrace

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.