is it possible to edit code while debugging in visual studio, like in eclipse (java)

45,341

Solution 1

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.

Solution 2

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)

Solution 3

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.

Share:
45,341
oshai
Author by

oshai

Kotlin & Java developer, new technologies enthusiast. likes beautiful code when I see it.

Updated on February 04, 2020

Comments

  • oshai
    oshai over 4 years

    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.

  • Oscar Mederos
    Oscar Mederos about 13 years
    Is this feature disabled by default?
  • T.J. Crowder
    T.J. Crowder about 13 years
    @Oscar: Not in my experience, with VS.Net 2005 or VS.Net 2008.
  • Anton Semenov
    Anton Semenov about 13 years
    Please note, that you cannot use edit and continue if you have Intelli trace enabled (VS2010)
  • T.J. Crowder
    T.J. Crowder about 13 years
    @ohadshai: Sorry, don't know, I've never used the office add-in.
  • Veysel Ozdemir
    Veysel Ozdemir about 8 years
    @AntonSemenov your comment is absolutely vital. Disabling Intellitrace made it work for me.
  • Joel Wiklund
    Joel Wiklund over 4 years
    For asp.net core 3.0 look here: stackoverflow.com/questions/58173846/…