Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Edit and Continue: "Changes are not allowed when..."

Other Applicable Solutions

Below is an incomplete, unordered list of possible solutions to try if you* are trying to fix Edit & Continue quickly.

  • Make sure you are in Debug Mode
  • Make sure you're not launching a mixed mode process
  • Try to set the CPU target to x86 rather than AnyCPU (on x64 machines)
  • Uncheck the Optimize Code checkbox for Debug Mode in Project Properties->Debug
  • Uncheck Enable Optimizations in Advanced Compiler Settings
  • (ASP.NET) Check nightcoder's answer if it is the case
  • (ASP.NET) Check this answer (by matrixugly) if it is the case
  • (ASP.NET) Ensure you have Edit and Continue enabled on the Web tab (vs2010)
  • (ASP.NET) Go to Properties > Web > Servers, and make sure that Enable and continue is checked under Use Visual Studio Development Server.
  • (ASP.NET WebAPI) Make sure you've stopped in the Controller's method using a breakpoint, before trying to edit it.
  • (vs2017) Go to Tools > Options > Debugging and uncheck (deselect) 'Edit and Continue'. This is actually the opposite of the 'conventional' advice (see some other points in this post). It does not allow you to actually make changes in your running program (i.e. it does not hot-swap the code changes that you make) - it simply allows you to edit your code (i.e. it prevents that annoying message and "locking" your editor).
  • Go to Tools > Options > Debugging > General and make sure Require source files to exactly match the original version is unchecked.
  • Check Enable Windows debug heap allocator (Native only) [VS Community 2017]
  • Are you using Microsoft Fakes? It inhibits Edit & Continue.
  • Kill all the *.vshost.exe instances by selecting End Process Tree in the Task Manager. VS will regenerate a correct instance.
  • Remove all the breakpoints with Debug->Delete All Breakpoints
  • Enable and Continue exists in both the Tools > Options > Debugging menu and also in the Project Settings. Be sure to check both places. edit & Continue is not supported with the extended Intellitrace setting.
  • Be sure Debug Info in Project Properties > Build > Advanced > Output > Debug Info is set to Full
  • Some plugin may be interfering. Check by disabling/uninstalling and then trying again the other solutions.
  • If you're not paying enough attention, the error you get while trying to fix this may change to something else that is easier to diagnose. E.g. A method containing a lambda expression cannot support edit and continue.
  • Make sure the System variable COR_ENABLE_PROFILING is not set to 1. Some profilers set this when installing and leave it like that after uninstalling. Open a command prompt and type set to quickly check it your system is affected, if so remove the variable or set it to 0:

    • In Windows 8 and above, search for System (Control Panel).
    • Click the Advanced system settings link.
    • Click Environment Variables.
    • Remove COR_ENABLE_PROFILING
  • Be aware of unsupported scenarios (as reported in the question) and that unsupported edits.


* by 'you', I mean the visitor of the page who is hammering his head on a keyboard to find The solution.


Feel free to edit this answer to add your workaround if not listed here!


If you're debugging an ASP.NET application, go to properties > web > Servers, and make sure that "enable and continue" is checked under Use Visual Studio Development Server.


I finally got to solve the problem: UNINSTALL Gallio

Gallio seems to have quite some many rough edges and it's better to not use MbUnit 3.0 but use the MbUnit 2.0 framework but use the gallio runner, that you are running without installing from the installer (which also installed a visual studio plugin).

Incidentally, I had the issue even after "disabling" he Gallio plugin. Only the uninstall solved the problem.

PS. Edited by nightcoder:
In my case disabling TypeMock Isolator (mocking framework) finally helped! Edit & Continue now works!!!

Here is the answer from TypeMock support:

After looking further into the edit and continue issue, and conversing about it with Microsoft, we reached the conclusion it cannot be resolved for Isolator. Isolator implements a CLR profiler, and according to our research, once a CLR profiler is enabled and attached, edit and continue is automatically disabled. I'm sorry to say this is no longer considered a bug, but rather a limitation of Isolator.


I had the same problem. I even re-installed VS 2008 but the problem did not go away. However, when I deleted all the break points then it started to work.

Debug->Delete All Breakpoints

I think it was happening because I had deleted an aspx page that had break points in its code, and then I created another page with the same name. This probably confused the VS 2008.


"Edit and Continue", when enabled, will only allow you to edit code when it is in break-mode: e.g. by having the execution paused by an exception or by hitting a breakpoint.

This implies you can't edit the code when the execution isn't paused! When it comes to debugging (ASP.NET) web projects, this is very unintuitive, as you would often want to make changes between requests. At this time, the code your (probably) debugging isn't running, but it isn't paused either!
To solve this, you can click "Break all" (or press Ctrl+Alt+Break). Alternatively, set a breakpoint somewhere (e.g. in your Page_Load event), then reload the page so the execution pauses when it hits the breakpoint, and now you can edit code. Even code in .cs files.


Couple of things to check

  • Make sure your compile is set to Debug vs. Release
  • Make sure you're not launching a mixed mode process
  • If on a 64 bit machine Make sure to set the CPU target to x86 rather than AnyCPU

EDIT

I don't believe this should matter but make sure that the hosting process is enabled for the target platform. Probably won't help.

If it repros for new projects then it might be something even more subtle. I would try the following.

  • Backup HKCU:\Software\Wow6432Node\VisualStudio\9.0 (maybe just rename it)
  • Delete the same key
  • Try the repro again

None of the above solutions worked for me(running on a 64x machine).

Finally I clicked on 'advanced compiler settings' and UNCHECKED 'enable optimizations' and I can now step through code and edit while debugging.