115

Even if I create a clean WinForms project, Edit and Continue doesn't work and gives me the error:

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.

  1. Edit and Continue option is checked in Tools → Options → Debugging.
  2. Optimization is not enabled.
  3. Seems like there is no any managed profiler set up.
  4. I am running in Debug mode
  5. I am running on x64 CPU and Windows XP 32-bit, but setting platform target to x86 rather than AnyCpu doesn't help.
  6. Repairing Visual Studio installation doesn't help.

I also found this article on MSDN website:

Unsupported Scenarios

Edit and Continue is not available in the following debugging scenarios:

  • Debugging on Windows 98.

  • Mixed-mode (native/managed) debugging.

  • SQL debugging.

  • Debugging a Dr. Watson dump.

  • Editing code after an unhandled exception, when the "Unwind the call stack on unhandled exceptions" option is not selected.

  • Debugging an embedded runtime application.

  • Debugging an application with Attach to rather than running the application with Start from the Debug menu.

  • Debugging optimized code.

  • Debugging managed code when the target is a 64-bit application. If you want to use Edit and Continue, you must set the target to x86. (Project Properties, Compile tab, Advanced Compiler setting.).

  • Debugging an old version of your code after a new version failed to build due to build errors.

But I can answer "No" to every item in this list.

It worked before, but several days ago it stopped working, and I don't know what could be the reason.

10
  • 3
    Are you running in Release mode? Are you running on X64? Commented Jun 18, 2009 at 0:42
  • Is the method you are trying to E&C really short? perhaps it got inlined (though i think inlining does not happen on debug) Commented Jun 18, 2009 at 0:46
  • It doesn't work on any methods, either very short or very long. Commented Jun 18, 2009 at 0:47
  • Did you try a repair installation yet? Commented Jun 18, 2009 at 14:22
  • 3
    I guess I should add that E&C is a pretty complex feature. The debugger's test matrix is enormous, and getting E&C to work in every combination would be extremely hard. But it's a really important feature, too, so we took on a lot of limitations to make sure it would ship. Within the deliberate constraints we placed on it, it's one of the highest-quality features we shipped. Commented Jan 17, 2010 at 4:47

38 Answers 38

1
2
0

I had a database project in the solution which stopped the webforms project from being editted.

I clicked "Unload" on the database project and everything now works sweetly.

Sign up to request clarification or add additional context in comments.

Comments

0

For VS2017 it can help to remove the .suo file in your solution, it worked for me. :)

Comments

0

I was facing the same problem in Visual Studio 2005. My configuration is 64 bits. It was working fine on one of the VS solution but not the other. I noticed i only enabled "Enable edit and continue" for the project where i wanted to make changes in debug mode. This finally solved for me when I selected "Enable and Continue" for my start up project as well.

There was no configuration changes except the enable and continue needed.

Comments

0

For me, it was happening after I had hit a breakpoint, had done some edits, then continued on stepping through the code, then finally hit F5 or "Continue" to get to the end and out of my code block.

After trying the "delete all breakpoints" option (Ctrl+Shift+PrtScn and OK on the prompt) and doing a Rebuild All, I still had an error in my Error Log with regard to my DLL for my project not loading... "Can't apply changes, x.DLL not loaded". After restarting Visual Studio, all was fine again. For me, it turned out to be just this simple.

Other things here did not work for me, like "Require source files to exactly match the original version" was checked before and after things started working again just fine, and targeting "Any CPU" on my x64 machine is just fine, too (did not need to specify x86 or x64). I had "Enable Edit and Continue" enabled in my Tools > Options > Debugging and in my Project Properties > "Web" tab settings.

Comments

0

Had this problem in Rider. I had opened the .csproj file directly instead of the .sln file. The consequence is that the runtime configuration was not set to debug even though I clicked the debug button. You'll notice it says <No Configurations> in the toolbar beside the debug button.

Comments

0

VS2019 - ASP.NET Forms In my case was Tools - Options - Windows Forms Designer - "Optimized Code Generation" <- to false

Comments

0

Edit and Continue has not worked for these 2 particular projects since VS2013 so I have kept it around for those. A fresh attempt to get it working on VS2022 finally yielded a cause:

On Error

If you edit code within an On Error you get the "edits were made which cannot be compiled" error. Setting the Error list Show Options to Build + Intellisense you finally see the error "Updating a On Error statement around an active statement requires restarting the application" which is what is blocking continuing execution.

Sad, as I have intentionally kept this legacy error handling method for these two particular projects for a very specific reason and needing to go to structured error handling is a major productivity setback.

But now I need to use some more modern libraries which are no longer compatible with VS2013 so I am forced to move on.

Comments

0

The solution for our case was disabling the Telerik JustMock Profiling. In Visual Studio 2022 the Hot Reload was only working when running without debugging (CTRL+F5).

If try to run in debug mode (F5) and edit a .cshtml file, the error message appears:

Hot Reload can't automatically apply your changes. The app needs to be rebuilt to apply updates.

Visual Studio - Hot reload can't apply changes error message

Additionally, at the error tab on Visual Studio, there is another message:

ENC2018 Changes made in project 'Project.Name' require restarting the application: Changes are not allowed when 'COR_ENABLE_PROFILING' environment variable is set.

Visual Studio - Changes Required Restarting because of COR_ENABLE_PROFILING

So the cause is the Registry (Regedit) key COR_ENABLE_PROFILING (Regedit) at Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\.NETFramework, and they are created if we activate the Progress/Telerik Just Mock Profiling extension, that we use in old projects in Visual Studio 2017.

Disable Telerik JustMock extension on VisualStudio

After turning it off, and restart the debugging app on VS2022, the debugging and hot reload can work together! 🔥

Comments

1
2

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.