satyajit
satyajit

Reputation: 2700

Modifying the code while debugging in VS 2010

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.

Upvotes: 16

Views: 13931

Answers (3)

fIwJlxSzApHEZIl
fIwJlxSzApHEZIl

Reputation: 13280

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.

Upvotes: 2

Kate Gregory
Kate Gregory

Reputation: 18954

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.

Upvotes: 17

tobias86
tobias86

Reputation: 5029

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.

Upvotes: -4

Related Questions