Edit and Continue: “Changes are not allowed when…”

谁说胖子不能爱 提交于 2019-11-27 10:30:54
nightcoder

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.

beppe9000

Applicable Solutions

Here is an incomplete, unordered list of possible solutions to try if you* want 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.
  • Go to Tools > Options > Debugging > General and make sure Require source files to exactly match the original version is unchecked.
  • 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 if you have other tips!

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.

Amer

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.

Protector one

"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

If your concern is with an ASP.NET app, ensure you have edit and continue enabled on the web tab (vs2010). There was also a separate setting for ASP.NET debugging in earlier versions.

Regards,

Adam.

Nifle

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.

I found that even though under project properties build & debug tab are set to Debug and all the other setting are correct I still get the message, however after digging some more under the Build menu select Configurations Manager... and make sure Debug is selected in two places there as well. go figure...how many different places do they need to set debug?????? even though you set Project - Configuration to Debug then under Build - Manager it is not changed so you have change the same setting there as well Project Configuration - seems like a microsoft issue again.......

This problem is due to Intellitrace setting

If Intellitrace is enabled make sure Intellitrace event only is checked

Otherwise this will not allow edit and continue..

If you will click on Intellitrace options you will see the warnings.

Following shooting helped me using VS2010:

go to Tools, Options, Debugging, General and make sure "Require source files to exactly match the original version" is unchecked.

For me, for a reason that I don't understand, the setting "Generate debug info" in the "Advanced Compiler Settings" was set to "pdb-only" instead of "Full".

By default, this parameter is always set to "Full" but a mysterious poltergeist has changed this parameter on last night. :)

P.S. I'm in Visual Basic .Net with Visual Studio 2010

I had this problem in Microsoft Visual Studio 2008 and the solution is easy. when you run your project please set in "Debug" mode not "Release". The another people solution can be useful.

That happens when the debugger hasn't hit a breakpoint or you haven't hit Break All (pause). It couldn't be that simple could it?

The error says a possible cause is: "the code being debugged was optimized at build or run time". Go to Project Properties->Debug and uncheck the Optimize Code box for Debug mode.

If I create a new project, edits while debugging do not work. If I create a new website, edits while debugging work as expected.

Scott

Some things that seemed to help using VS2010:

  • go to Tools, Options, Debugging, General and make sure "Require source files to exactly match the original version" is unchecked.
  • multiple .vshost.exe instances can be left over from e.g. detaching the VS debugger from a stopped process. This will interfere with breakpoints and compiles as well. Use Task Manager, Processes tab to kill all instances of .vshost.exe by right-clicking each instance and selecting End Process Tree. VS will create a new instance.
ashkan_jami

I removed a dataset from my project because I didn't use it. After that I could modify the program when debugging.

I did all the changes mentioned in every other answer and none worked. What did I learn? Enable and Continue exists in both the Tools > Options > Debugging menu and also in the Project settings. After I checked both, Enable and Continue worked for me.

I ran into this today - turns out that having Debug Info set to pdb-only (or none, I'd imagine) will prevent Edit and Continue from working.

Make sure your Debug Info is set to "full" first!

Project Properties > Build > Advanced > Output > Debug Info

B. Cafaro

what worked for me was unchecking "Use Managed Compatibility Mode" under

Tools -> Options -> Debugging

TBN: checking or unchecking "Require source file to exactly match the original version" seems not influences the E&C

Hope this can help.

Enable edit and Continue only work run IIS Express. Don't work in Local ISS or External Host.

In my case just reseting to default debugger settings and setting IntelliTrace-> only intellytrace events helps

embed interop types visual studio should be set to false

I had this happen in a linked class file. The rest of the project allowed E&C, but I got the same error editing the linked file. Solution was to break linked file into it's own project and reference the project.

I faced the same problem. My problem was that I could modify a file, but not another (both are in same project). Later I found that the file I couldn't modify was also part of another project. That another project (Unit Test) wasn't loaded, and intelligent VS debugger shows the error that assembly for this given file was not loaded, and changes aren't allowed. How weird!

Hence, I had to unload the unit-test project and continue the EnC debugging.

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.

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

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.

Seems illogic, but only way was disabling edit and continue from VS 2017 options... Then AspNet edit and continue began to work...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!