views:

1100

answers:

5

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.

+1  A: 

You need to enable Edit and Continue.

Reed Copsey
In addition, you need to be at a breakpoint, or click the pause (Break All) button.
McAden
And be running 32 bit code.
marcc
@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
A: 

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 lamda expressions

Johannes Rudolph
+4  A: 

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

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

Secko
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
A: 

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
JaredPar
+1  A: 

With the feature off, the editor should allow you to make your changes, however, VS2008 is broken in this fashion. Before, you could figure out your changes, make them, and then go back to the program and do more things... And your changes were applied when you stopped the program and re-ran it. No more... You are stuck using an external editor if you want to do that.. Or praying that the edit and continue works - I've never had it work, mostly because the stupid thing won't let you edit when you are running.

Good grief, I want the editor to just be an editor, and if my source code mis-matches what is running, go ahead and pop up a dialog saying so when I continue from a break point (Delphi did it right, like everything else they did.)

Older versions of VS worked as expected too..

Would be nice if Microsoft would allow an option to not disable editing of files.

-Chert