16

I am new to VS 2010 and am facing problem to Modify the code while debugging..Please help me If there is any setting so achieve this.

satyajit
  • 2,540
  • 11
  • 33
  • 44
  • possible duplicate of [Edit and Continue: "Changes are not allowed when the debugger has been attached to an already running process or the code being debugged was optimized at build or run time"](http://stackoverflow.com/questions/1010213/edit-and-continue-changes-are-not-allowed-when-the-debugger-has-been-attached) – Cees Timmerman Feb 03 '15 at 16:04

3 Answers3

17

According to http://connect.microsoft.com/VisualStudio/feedback/details/520179/vs2010-sp2-x86-unable-to-edit-and-continue Edit and Continue is supposed to be possible in ASP.NET projects with Visual Studio 2010, but only while you are stopped at a breakpoint.

Here are the steps from the Microsoft answer there to make sure Edit and Continue is turned on, and to see if it's working for you:

  1. File > New Project, select C#, create a new Web Application
  2. Go into the Default.aspx.cs file
  3. Put a breakpoint at the Page_Load function
  4. Open project properties, choose the Web tab, select "Enable Edit and Continue", hit save, close the property pages
  5. Hit F5 on your Default.aspx
  6. When the breakpoint is hit, try to create a new variable inside the Page_Load function by writing the following lines of code:

    int i = 1; i += 5;

  7. Hit F10 (or hit step into)

  8. See the new code get hit, you can hover over variables to get their values.
Kate Gregory
  • 18,808
  • 8
  • 56
  • 85
2

I was getting this in Visual Studio 2010 while working on a C# project remotely.

The key here is: Tools -> Options -> Debugging -> Edit and Continue -> 'Enable while remote debugging or running under another user name' at the bottom.

fIwJlxSzApHEZIl
  • 11,861
  • 6
  • 62
  • 71
-4

VS2010 has a nice error message that says:

Changes are not allowed while code is running or if the option 'Break all processes when one process breaks' is disabled. The option can be enabled in Tools, Options, Debugging.

Changes are not allowed while code is running is pretty clear. The reason for this is that your code needs to be compiled before running. To make any changes you need to stop execution, make your change and recompile the code again.

If you want to run ad hoc code to check variables etc. use the "QuickWatch" option in your context menu, or the "Immediate" window.

tobias86
  • 4,979
  • 1
  • 21
  • 30
  • 11
    actually "While code is running" means "while you are not at a breakpoint" – Kate Gregory May 26 '11 at 12:55
  • Indeed. There could be background threads running concurrently that are trying to access data you would then be editing in the editor by either things such as the immediate window or by just clicking the variable and modifying its value. – fIwJlxSzApHEZIl Feb 11 '13 at 21:57
  • 2
    I just wish it would allow me to edit the code now and continue to run on the old code. This way I can make a number of modifications during the debug session without having to stop and restart. I don't care if the break points become slightly off by a line or two. – Joan Charmant Jul 25 '13 at 08:08
  • 1
    All I want is for the @#$%^ IDE to stop debugging. I've been using VS for over a decade and continue to run into the idiotic dialog "Changes not allowed to 64 bit applications" with nothing but an OK option to clear the dialog. This is not helpful. It is a waste of time. – David Tansey Oct 15 '13 at 20:44
  • 2
    In VS2013, _disabling_ Edit & Continue gets rid of this annoying dialog and allows you to make edits. Bizarre. – Jon Feb 05 '14 at 01:58