149

Is there a way to enable file editing while debugging in Visual Studio? I have unchecked the "Require the source file to exactly match the original version" checkbox. It makes no difference. I have to stop debugging to edit files. Very annoying. I enabled Edit and Continue. Same result. I disabled Edit and Continue - Same result.

tom7
  • 4,062
  • 8
  • 30
  • 30
  • I didn't see that you edited your question. You can fix that with a quick reinstall. – Secko Feb 02 '14 at 13:56
  • 13
    @Secko There is no such thing as a "quick reinstall" when we are talking about Visual Studio... – Zero3 Mar 15 '16 at 13:48
  • @Zero3 There was in my time, about 16 or so years ago, when I was using it around (int)1999 - (int)2000. Haven't used it in a (long) *time. – Secko Feb 23 '17 at 22:01
  • The real problem here is that Visual Studio's 'Edit and Continue' setting *doesn't enable you to edit and continue*. Rather, it's a weird feature that lets you edit code, then actually *changes the executing code* to match your edit, and debugs from there. Even if that were useful, it rarely works. It should have been called something like 'edit and recompile on the fly'. Switching it *off* allows you to actually edit your code while still debugging the code you compiled. – MGOwen Mar 28 '18 at 01:16

12 Answers12

246

As far as I know you can uncheck the "Edit and Continue" checkbox.

Tools -> Options -> Debugging -> Edit and Continue > Enable Edit and Continue (uncheck)

Secko
  • 7,664
  • 5
  • 31
  • 37
  • 67
    This was the solution for me - I have no idea why UN-checking "Edit and Continue" would allow me to Edit...seems counterintuitive. Anyway, I would mark this as the answer. – Sam Schutte Aug 26 '09 at 14:00
  • 7
    Counter-intuitive, yet, effective. – Milne May 21 '13 at 19:10
  • 2
    This reacts differently if the business layer is split into a separate project within the solution. Before it was split I was able to edit classes while debugging without a problem. Unfortunately this solution has not solved for me in this situation (am using VS2013) – Radderz Jul 31 '14 at 12:19
  • 1
    Worked for me too in Visual Studio 2013. Disabling "Edit and Continue" removes all of the limitations that normally apply in this mode, so you can freely edit your source code while the program is running. Counterintuitive, but true. – Contango Aug 17 '15 at 18:18
  • In VS 2015, a C# ASP.NET web project, I was unable to edit until I **checked** "Enable Edit and Continue". *Sigh* – EM0 Nov 25 '15 at 13:59
  • 18
    In Visual Studio 2015, I found this setting at the bottom of `Debugging` -> `General`. – Zero3 Mar 15 '16 at 13:54
  • its weird how unchecking the option actually makes it work,i can confirm this is the solution on visual studio 2015 update 2 enterprise edition. – Niklas Apr 16 '16 at 09:24
  • Not Working for me. If it is checked, I can edit, but then Visual Studio tells me changes won't apply. If unchecked, I simply cannot edit. – Rafiki Jul 28 '16 at 12:48
  • My "Enable Edit and Continue" was already checked, but I was unable to edit my files while debugging. I unchecked this. Did a build and ran the app and stopped it. Then I REchecked it and built it again. I could then edit and continue as expected. – Francois Botha Oct 25 '16 at 09:58
  • 14
    If you're trying to do this, but "Enable Edit and Continue" is greyed out, simply stop debugging and go back into the options. – Ravvy Dec 20 '16 at 18:11
  • For some reason, when I have this unchecked I'm unable to run my Web project and I get the message "Unable to launch IIS Express web server". No idea why the two are linked. – Steve Smith Jan 12 '17 at 09:31
  • VS2017 decides to randomly lock files for editing... – Alexander May 30 '18 at 17:07
  • Yet it ... disables Edit and Continue. I'd like to keep that ... – Paul Apr 02 '20 at 12:25
  • Confirmed: what a wacky unintuitive decision, but "edit and continue" is turned on by default, and with that turned on, you can only edit in very specific scenarios, described below. If you don't need to edit "and continue", you just need to *edit*, you can just uncheck that option. Such a pain! – neminem Jan 27 '21 at 00:47
20

Expanding on Reed's correct answer.

When in debug mode editing a file is using a feature known as Edit and Continue (commonly abbreviated ENC). This allows users to change their program as it is running in the debugger.

When ENC is enabled, users are allowed to perform a limited set of edits on their file. The next action which continues execution of the program (F10, F5, etc ...) will cause the edits to be applied to the running program. If this succeeds the execution of the program will continue with the new code applied.

The debugger does not allow edits to the file if ENC is not enabled.

There are a few reasons ENC may be disabled on your computer

  • Certain profiles do not enable ENC by default and it must be explicitly enabled
  • You may be running on a 64 bit OS and have your .Net app set to "Any CPU". ENC is not available on 64 bit (CLR limitation). You'll have to set the app back to x86 for ENC to work
Tim Abell
  • 11,186
  • 8
  • 79
  • 110
JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454
  • 10
    What if you don't care about Edit and Continue and just want to code while the app is running so you can see what needs to be done while you're doing it? It's absolutely unreal VS would impose this artificial restriction. It's not like it needs to read the source files while it is running. There's no technical reason why it should have to lock the source files. Xcode has no problem letting you code while the app is running. The changes just don't apply until the next run. Is there truly no way to do this in VS? – devios1 Nov 04 '16 at 16:56
  • 1
    If I *disable* Edit and Continue it will let me edit .cs files while the app is running, but it still locks .xaml files. I'm looking for a way to disable this absurd locking entirely. – devios1 Nov 04 '16 at 17:00
  • 8
    It won't even let me *add a file to the project* while the app is running! I kid you not, 20-30 times a day I try to do something and VS completely prevents it. After a brief "wtf" moment I realize the app is debugging and I have to stop what I was doing, kill the app, and then reattempt it. I can't work under these conditions and am really amazed people aren't up in arms about this. This is really killing my productivity and driving me up the wall. There has to be a way to fix this! – devios1 Nov 04 '16 at 18:46
  • 1
    @devios1 Something I often do is just run without debugging (ctrl+f5) which is OK as long as you do not need breakpoints or anything. – binki Feb 07 '18 at 23:07
  • @devios1 Same. I hope someone (maybe me) will find the time to finish this extension. https://github.com/AndreasFurster/pause-edit-and-continue – Paul Apr 02 '20 at 12:28
9
  • UNcheck "Enable Edit and Continue" (Tools -> Options -> Debugging -> Edit and Continue > Enable Edit and Continue)
  • Build your app.
  • Run it.
  • Stop it.
  • REcheck "Enable Edit and Continue".
  • Build your app.
  • Run it.
  • Try editing the files while debugging now.

This worked for me. I believe it might be some bug or syncing issue with Visual Studio 2015.

Francois Botha
  • 4,520
  • 1
  • 34
  • 46
6

You need to enable Edit and Continue.

Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
  • 2
    In addition, you need to be at a breakpoint, or click the pause (Break All) button. – McAden Jul 09 '09 at 17:26
  • @marcc: And many other things, which is why I pointed to the docs. For the complete list of unsupported changes, see the section "Unsupported Scenarios" at this location: http://msdn.microsoft.com/en-us/library/ms164927%28VS.80%29.aspx – Reed Copsey Jul 10 '09 at 17:49
  • 4
    Seckos (best rated) answer worked for me (VS2015) and is the exact opposite of your answer. – alrts Jun 29 '17 at 16:01
6

From MSDN

To enable/disable Edit and Continue

  • Open debugging options page (Tools / Options / Debugging). Scroll

  • down to Edit and Continue category. To enable, select the Enable Edit

  • and Continue check box. To disable, clear the check box. Note. ...

  • Click OK.

Dilaksha A
  • 279
  • 3
  • 4
5

usually editing a file during debugging is possible when you have hit a breakpoint (and only then).

There are some restrictions though: -your new code must compile -you cant change code in a function that contains lambda expressions

Romano Zumbé
  • 7,893
  • 4
  • 33
  • 55
Johannes Rudolph
  • 35,298
  • 14
  • 114
  • 172
4

For me this link Disabling IntelliTrace worked.
Go to

Tools > Options > IntelliTrace > (uncheck) Enable IntelliTrace

Or Debug > Options > IntelliTrace > (uncheck) Enable IntelliTrace

enter image description here

Muhammad Ashikuzzaman
  • 3,075
  • 6
  • 29
  • 53
2

If you have Edit and Continue turned on and you are using C# you can only edit a file if the debugger has stopped either via a break point or you manually breaking into the App via "Break All". You still won't be able to edit some files, Ex. xaml files in a WPF app, but it should solve most problems.

2

Removing tick at below option work for me

Tools > Option > Debugging > General > Enable Edit and Continue

enter image description here

*Note: At some fellow developers system, Adding this tick performed the trick.

Pranav Labhe
  • 1,943
  • 1
  • 19
  • 24
1

If your source origins from a decompiled dll, note that decompilers may add an IgnoreSymbolStoreSequencePoints instruction to assemblyinfo.cs:

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]

This line must be removed in order to load the pdb-file, making edit & continue work.

Turbo
  • 101
  • 1
  • 6
1

I have tried this way and its Working for me. Go TO CSProj Or VbProj File -> Choose Asp.Net Development Server/ IIS Express ->Debuggers->Enable Edit and Continue->Save and Run.

enter image description here

0

Click Tools -> Option: and then make sure the following is selectted:

enter image description here

lennoxGER
  • 284
  • 1
  • 6