24
votes

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.

10
There are several useful answers to another question.Dialecticus
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 pageHans Passant
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 problembrtb

10 Answers

15
votes

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....

11
votes

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

9
votes

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

7
votes
  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.
6
votes

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!

1
votes

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.

0
votes

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.

0
votes

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.

0
votes

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://docs.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();

-3
votes

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