28

In my project which is a hybrid project (in previous it was a web forms project that then we modified to use mvc pattern).

Now I want that in debug mode, I want to change something in my cs file, and then I want the changed code to run.

I've tried enabling and disabling tools -> options -> debug -> edit and continue checkbox part.

When it is enabled I can't change code in my project while debugging. When it is disabled I can change code but it does not affect on running part. for example.

  int i = 0;
  if(i == 1)
    return 1;
  else
    return 2;

In debug mode I changed i to 1 but it stil returned 2, in the following code, only when I stop and re-run the debugger it takes affects.

 int i = 1;
  if(i == 1)
    return 1;
  else
    return 2;

BTW I am using Visual Studio 2010 version.

Erick Santander
  • 311
  • 3
  • 17
brtb
  • 2,201
  • 6
  • 34
  • 53
  • 2
    There are several useful answers to [another question](http://stackoverflow.com/q/4782057/395718). – Dialecticus Aug 16 '13 at 09:09
  • It ought to be a *bit* obvious that **disabling** edit and continue does not make the code change behavior when you edit it. E+C has some limitations, in particular it is not supported for 64-bit programs. Fixed in VS2013. Microsoft does not keep it a secret, what can work is well described in [this MSDN page](http://msdn.microsoft.com/en-us/library/vstudio/ms164927%28v=vs.100%29.aspx) – Hans Passant Aug 16 '13 at 09:45
  • as a result what should i do it says that enable E+C but the thing i m saying is that i tried two cases but it didnt solve my problem – brtb Aug 16 '13 at 10:45

11 Answers11

16

This wasn't my problem; running VS2017 RC2, I found that under Tools -> Options -> Debugging -> Just-In-Time - my "Managed Code" was deselected.

There was a warning "Another debugger has registered itself as the Just-In-Time debugger. Fix by enabling Just-In-Time debugging or running Visual Studio repair".

I had not registered any other debugging tools! So no idea why it unticked...

So the fix was simply to tick the "Managed" box....

James Joyce
  • 1,694
  • 18
  • 20
  • I had to do this and also restart Visual Studio for the change to take effect – Zout Nov 22 '17 at 20:25
  • Same here. _Native_ was originally the option, but ended up selecting all three. On some setups, attempting to change these without elevation again incurs the "Another debugger has registered itself…". – Laurie Stearn Jan 22 '19 at 13:48
14

None of the given answers worked. Here's what I did.

  • I repaired the VS installation. I had 2017 version.
  • I unticked the Native code checkbox.

enter image description here

h-rai
  • 3,636
  • 6
  • 52
  • 76
10

None of the above worked for me on their own, but once I unchecked "Enable Native Edit and Continue" then it worked: under Tools -> Options -> Debugging -> General.

enter image description here

voxoid
  • 1,164
  • 1
  • 14
  • 31
7
  1. Under Tools -> Options -> Debugging -> General: Check the box for 'Enable Edit and Continue'.
  2. Under Tools -> Options -> Debugging -> Just-In-Time: Check the box for 'Managed Code' Image Checking Managed Code
  3. Save and restart Visual Studio. If you get a warning about elevated permissions, accept the dialog. Your changes are not saved yet. After restart, go again to Tools -> Options -> Debugging -> Just-In-Time: Check the box for 'Managed Code' if not showing checked. Save and restart Visual Studio.
Ashok Garg
  • 73
  • 1
  • 4
6

The solution of this problem is on the Microsoft Documentation... After you enable tools-> options -> debud -> edit and continue.... There is more to do..

If IntelliTrace is enabled and you collect both IntelliTrace events and call information, Edit and Continue is disabled.

On Visual studios' menu go on Tools>>options - Select "IntelliTrace" tab and let IntelliTrace events only checked.. Save, restart the visual studio and.......

Your Edit and Continue will work again!

Thiago Araújo
  • 800
  • 9
  • 8
1

I discovered that my

VS2019: Project (context menu) =>
Properties =>
Debug =>
Debugger engines =>
Enable native code debugging

was turned on. After unchecking this my "Edit and Continue" issues disappeared!

Note: I had tried suggested fixes (here) prior to this discovery.

Neverlyn
  • 31
  • 5
0

Edit & Continue doesn't work - this has fixed it for me - it's for VS2017 and started happening recently (March 2019). It seems like NCover sets the system variable COR_ENABLE_PROFILING=1. Uninstalling it gets rid of it for me.

Ziarek
  • 679
  • 6
  • 14
0

Repairing the VS installation, and upgrading to the current latest VS2017 version: 15.9.19 fixed the issue for me.

h-rai's answer gave me the clues I needed: unchecking the Native checkbox made a warning appear stating that another JIT debugger was registered.

Then, I found more clues in this article here

Perhaps, my issues were caused by having installed the new .NET core 3.1, but not having upgraded VS2017 to VS2019 yet.

Now, when I uncheck the "Native" checkbox, I do not get the warning about another JIT debugger, and I can modify code while debugging once again.

Matthew Beck
  • 451
  • 5
  • 19
0

Before that, the Runtime Compilation was enabled by-default. For projects targeting .NET Core 3.0+ users need to explicitly enable that behavior by following the instructions https://learn.microsoft.com/en-us/aspnet/core/mvc/views/view-compilation?view=aspnetcore-3.0

install from Nuget package manager Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation

Run the below command:
Install-Package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation -Version 5.0.7 and add below line in Startup file

services.AddRazorPages().AddRazorRuntimeCompilation();

0

If you've already updated Debug options but Edit&Continue still doesn't work, try cleaning and rebuilding the project. (worked for me in VS 2022)

safinilnur
  • 199
  • 1
  • 4
-5

Just press the Break All button, then edit your code, then press Continue. It is work for me like a charm

enter image description here

Martin Brisiak
  • 3,872
  • 12
  • 37
  • 51