编辑并继续:“当……时不允许更改”

发布于 2024-07-25 01:13:38 字数 1142 浏览 8 评论 0 原文

即使我创建一个干净的 WinForms 项目,“编辑并继续”也不起作用并给出错误:

当调试器已附加到已运行的进程或正在调试的代码在构建或运行时进行了优化时,不允许进行更改。

  1. 在“工具”→“选项”→“调试”中选中“编辑并继续”选项。
  2. 未启用优化。
  3. 似乎没有设置任何托管探查器。
  4. 我在调试模式下运行
  5. 我在 x64 CPU 和 Windows XP 32 位上运行,但将平台目标设置为 x86 而不是 AnyCpu 没有帮助。
  6. 修复 Visual Studio 安装没有帮助。

我还在 MSDN 网站上找到了这篇文章

不支持的场景

“编辑并继续”在以下调试场景中不可用:

  • 在 Windows 98 上调试。

  • 混合模式(本机/托管)调试。

  • SQL 调试。

  • 调试 Dr. Watson 转储。

  • 未选择“在未处理的异常上展开调用堆栈”选项时,在未处理的异常之后编辑代码。

  • 调试嵌入式运行时应用程序。

  • 使用“附加到”来调试应用程序,而不是使用“调试”菜单中的“启动”来运行应用程序。

  • 调试优化代码。

  • 当目标是 64 位应用程序时调试托管代码。 如果要使用“编辑并继续”,则必须将目标设置为 x86。 (项目属性、编译选项卡、高级编译器设置。)。

  • 在新版本由于构建错误而无法构建后,调试旧版本的代码。

但我可以对此列表中的每一项回答“否”。

以前可以用,但是前几天就不行了,不知道是什么原因。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(30

攒眉千度 2024-08-01 01:13:39

如果您正在调试 ASP.NET 应用程序,请转到“属性”>“ 网络> 服务器,并确保在“使用 Visual Studio 开发服务器”下选中“启用并继续”。

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.

二智少女猫性小仙女 2024-08-01 01:13:39

我终于解决了这个问题:卸载Gallio

Gallio似乎有很多粗糙的边缘,最好不要使用MbUnit 3.0,而是使用MbUnit 2.0框架,而是使用你正在运行的gallio runner无需从安装程序安装(还安装了 Visual Studio 插件)。

顺便说一句,即使在“禁用”Gallio 插件后我也遇到了这个问题。 只有卸载才能解决问题。

PS。 由 nightcoder 编辑:
就我而言,禁用 TypeMock Isolator(模拟框架)终于有帮助! 编辑& 现在继续工作!

以下是 TypeMock 支持的答案:

进一步查看编辑后
并继续发出问题,并进行交谈
关于这个问题,我们与微软达成了协议
结论是无法解决
对于隔离器。 隔离器实现了
CLR 分析器,并根据我们的
研究,一旦 CLR 分析器
启用并附加,编辑和
继续将自动禁用。
我很遗憾地说这不再是
被认为是一个错误,而是一个
隔离器的限制。

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.

牵你手 2024-08-01 01:13:39

我有同样的问题。 我什至重新安装了VS 2008,但问题并没有消失。 但是,当我删除所有断点后,它就开始工作了。

Debug->Delete All Breakpoints

我认为发生这种情况是因为我删除了一个代码中有断点的 aspx 页面,然后我创建了另一个同名的页面。 这可能会让 VS 2008 感到困惑。

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.

二手情话 2024-08-01 01:13:39

“编辑并继续”启用后,仅允许您在处于中断模式时编辑代码:例如,通过因异常或命中断点而暂停执行。

这意味着在执行未暂停时您无法编辑代码! 在调试 (ASP.NET) Web 项目时,这是非常不直观的,因为您经常希望在请求之间进行更改。 此时,您(可能)调试的代码没有运行,但也没有暂停!
要解决此问题,您可以单击“全部打破”(或按 Ctrl+Alt+打破)。 或者,在某处设置断点(例如,在 Page_Load 事件中),然后重新加载页面,以便在遇到断点时暂停执行,并且现在您可以编辑代码。 甚至是 .cs 文件中的代码。

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

始终不够 2024-08-01 01:13:39

需要检查的几件事

  • 确保您的编译设置为“调试”与“发布”
  • 确保您没有启动混合模式进程
  • 如果在 64 位计算机上确保将 CPU 目标设置为 x86 而不是 AnyCPU

编辑< /strong>

我认为这并不重要,但请确保为目标平台启用托管进程。 可能不会有帮助。

如果它在新项目中重现,那么它可能会更加微妙。 我会尝试以下方法。

  • 备份 HKCU:\Software\Wow6432Node\VisualStudio\9.0 (也许只是重命名)
  • 删除相同的密钥
  • 再次尝试重现

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
吹梦到西洲 2024-08-01 01:13:39

上述解决方案都不适合我(在 64x 机器上运行)。

最后,我单击了“高级编译器设置”未选中 “启用优化”,现在我可以在调试时单步执行代码并进行编辑。

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.

甚是思念 2024-08-01 01:13:39

对我来说,由于我不明白的原因,“高级编译器设置”中的“生成调试信息”设置被设置为“仅 pdb”而不是“完整”。

默认情况下,此参数始终设置为“Full”,但昨晚神秘的恶作剧者更改了此参数。 :)

PS 我使用 Visual Basic .Net 和 Visual Studio 2010

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

九八野马 2024-08-01 01:13:39

如果您关心的是 ASP.NET 应用程序,请确保您已在 Web 选项卡上启用“编辑并继续”(vs2010)。 在早期版本中还有一个单独的 ASP.NET 调试设置。

问候,

亚当。

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.

時窥 2024-08-01 01:13:39

我发现即使在项目属性下 build & 调试选项卡设置为“调试”并且所有其他设置都正确我仍然收到消息,但是在挖掘了更多内容之后
在“构建”菜单下选择“配置管理器...”,并确保在两个位置也选择了“调试”。 想想看...他们需要在多少个不同的地方设置调试?????? 即使您将“项目 - 配置”设置为“调试”,然后在“构建 - 管理器”下它也没有更改,因此您也在那里更改了相同的设置“项目配置” - 似乎又是一个微软问题......

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

新雨望断虹 2024-08-01 01:13:39

此问题是由于 Intellitrace 设置造成的。

如果启用了 Intellitrace,请确保仅选中 Intellitrace 事件

,否则将不允许编辑并继续。

如果您单击 Intellitrace 选项,您将看到警告。

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.

梦里的微风 2024-08-01 01:13:39

以下拍摄帮助我使用 VS2010:

转到“工具”、“选项”、“调试”、“常规”,并确保“要求源文件与原始版本完全匹配”未被选中。

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.

草莓酥 2024-08-01 01:13:39

当调试器未到达断点或您未单击“全部中断”(暂停)时,就会发生这种情况。 事情不可能这么简单吧?

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?

丑疤怪 2024-08-01 01:13:39

该错误表明可能的原因是:“正在调试的代码在构建或运行时进行了优化”。 转到“项目属性”->“调试”,然后取消选中“调试模式”的“优化代码”框。

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.

故事未完 2024-08-01 01:13:39

我在 Microsoft Visual Studio 2008 中遇到了这个问题,解决方案很简单。 当您运行项目时,请设置为“调试”模式而不是“发布”模式。 另一个人的解决方案可能很有用。

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.

濫情▎り 2024-08-01 01:13:39

如果我创建一个新项目,调试时进行编辑将不起作用。 如果我创建一个新网站,则在调试时可以按预期进行编辑。

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

〃温暖了心ぐ 2024-08-01 01:13:39

我今天遇到了这个问题 - 事实证明,将调试信息设置为仅 pdb(或无,我想)将阻止编辑并继续工作。

首先确保您的调试信息设置为“完整”!

项目属性> 构建> 高级> 输出> 调试信息

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

沫尐诺 2024-08-01 01:13:39

就我而言,只需重置为默认调试器设置并设置 IntelliTrace-> 只有 intellytrace 事件有帮助

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

森末i 2024-08-01 01:13:39

有些东西似乎有助于使用 VS2010:

  • 转到“工具”、“选项”、“调试”、“常规”,并确保“要求源文件与原始版本完全匹配”未被选中。
  • 例如,将 VS 调试器与已停止的进程分离时,可能会留下多个 .vshost.exe 实例。 这也会干扰断点和编译。 使用任务管理器的“进程”选项卡通过右键单击每个实例并选择“结束进程树”来终止 .vshost.exe 的所有实例。 VS 将创建一个新实例。

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.
離人涙 2024-08-01 01:13:39

我从项目中删除了一个数据集,因为我没有使用它。 之后我就可以在调试时修改程序了。

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

苄①跕圉湢 2024-08-01 01:13:39

我做了所有其他答案中提到的所有更改,但没有一个起作用。 我学到了什么? 启用并继续存在于“工具”>“工具”>“工具”中。 选项> 调试菜单以及项目设置中。 在我检查了两者之后,“启用”和“继续”对我有用。

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.

木森分化 2024-08-01 01:13:39

似乎不合逻辑,但唯一的方法是禁用 VS 2017 选项中的编辑和继续...然后 AspNet 编辑并继续开始工作...

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

猫弦 2024-08-01 01:13:39

对我有用的是取消选中“使用托管兼容模式”

工具-> 选项-> 调试

TBN:选中或取消选中“要求源文件与原始版本完全匹配”似乎不会影响 E&C

希望这可以有所帮助。

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.

独孤求败 2024-08-01 01:13:39

启用编辑并仅继续工作运行 IIS Express。
不适用于本地 ISS 或外部主机。

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

酸甜透明夹心 2024-08-01 01:13:39

我添加我的答案是因为尚未明确提及为我解决问题的事情。 实际上对我有帮助的是这篇文章:

http://www.rubencanton.com/blog/2012/02/how-to-fix-error-changes-are-not-allowed-while- code-is-running-in-net.html

以下是解决方案的简短描述:

  1. 停止运行您的应用程序。
  2. 转到工具> 选项> 调试> 编辑并继续
  3. 禁用“启用编辑并继续”

请注意,这是多么违反直觉:我必须禁用(取消选中)“启用编辑并继续”。

这样您就可以在编辑器中更改代码,而不会收到“代码运行时不允许更改”消息。

但请注意,您所做的代码更改不会反映在您正在运行的程序中 - 因为您需要停止并重新启动您的程序(在我的脑海中,我认为模板/ASPX 更改确实会得到反映,但不会反映在 VB/C# 中)更改,即“代码隐藏”代码)。

I'm adding my answer because the thing that solved it for me isn't clearly mentioned yet. Actually what helped me was this article:

http://www.rubencanton.com/blog/2012/02/how-to-fix-error-changes-are-not-allowed-while-code-is-running-in-net.html

and here is a short description of the solution:

  1. Stop running your app.
  2. Go to Tools > Options > Debugging > Edit and Continue
  3. Disable “Enable Edit and Continue”

Note how counter-intuitive this is: I had to disable (uncheck) "Enable Edit and Continue".

This will then allow you to change code in your editor without getting that message "Changes are not allowed while code is running".

Note however that the code changes you make will NOT be reflected in your running program - for that you need to stop and restart your program (off the top of my head I think that template/ASPX changes do get reflected, but not VB/C# changes, i.e. "code behind" code).

痴意少年 2024-08-01 01:13:39

我安装了 stackify,当我在图标托盘上启用此功能时,它会通过编辑停止我的调试,所以我发现

  • 关闭 Visual Studio,在我的例子中是 vs2017
  • 转到图标托盘并右键单击 stackify 图标并禁用 .NET Profiler 使用
  • 调试器在调试模式下再次打开 Visual studio 运行应用程序,它允许我在调试时进行编辑

< img src="https://i.sstatic.net/bx6AI.png" alt="查看图片">

I install the stackify, when i enable this on icon tray, it stop my debugging with edit, so i found

  • Close the visual studio , in my case its vs2017
  • Go to icon tray and right click on stackify icon and disable .NET Profiler
  • Open Visual studio run application again in debug mode with debugger and it allow me edit while debugging

see image

与之呼应 2024-08-01 01:13:39

自从我将 VS 2019 升级到 16.4.3 后,我遇到了这个恼人的问题,让我很头疼。
最后我这样解决了问题:

1.停止调试
2. 从“解决方案资源管理器”中选择解决方案
3. 在属性窗口中,将“活动配置”属性从“发布|任何CPU”更改为“调试|任何CPU” “
4. 在调试> 选项> 一般检查编辑并继续复选框

这对我有用,希望对你也有用。

I had this annoying issue since I upgraded my VS 2019 to 16.4.3 and caused me a lot of headache.
Finally I solved the problem this way:

1. Stop Debugging
2. Select the solution from "Solution Explorer"
3. In the Properties window change the "Active config" Property From "Release|Any CPU" To "Debug|Any CPU"
4. In Debug > Options > General Check the Edit and Continue checkbox

That worked for me, and hope it works for you too.

独留℉清风醉 2024-08-01 01:13:39

嵌入互操作类型 Visual Studio 应设置为 false

embed interop types visual studio should be set to false

为人所爱 2024-08-01 01:13:39

我在链接的类文件中发生了这种情况。 项目的其余部分允许 E&C,但我在编辑链接文件时遇到了相同的错误。 解决方案是将链接文件分解到它自己的项目中并引用该项目。

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.

墨离汐 2024-08-01 01:13:39

我遇到了同样的问题。 我的问题是我可以修改一个文件,但不能修改另一个文件(两者都在同一个项目中)。 后来我发现我无法修改的文件也是另一个项目的一部分。 另一个项目(单元测试)未加载,智能 VS 调试器显示错误,未加载此给定文件的程序集,并且不允许更改。 多么奇怪啊!

因此,我必须卸载单元测试项目并继续 EnC 调试。

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.

入怼 2024-08-01 01:13:38

其他适用的解决方案:

下面是一个不完整的、无序的可能的解决方案列表,如果您*正在尝试修复编辑和编辑问题,可以尝试一下。 快速继续。

  • 确保您处于调试模式

  • 确保您没有启动混合模式进程

  • 尝试将 CPU 目标设置为 x86 而不是 AnyCPU(在 x64 计算机上)

  • 取消选中调试的优化代码复选框项目属性->调试

    中的模式

  • 取消选中优化代码 项目属性 -> 构建中的复选框

  • 取消选中高级编译器设置中的启用优化

  • (ASP.NET) 检查nightcoder 的回答(如果是这种情况)

  • (ASP.NET) 检查这个答案(由matrixugly)如果是这种情况

  • (ASP.NET) 确保您在Web 选项卡上启用了编辑并继续 (vs2010)< /p>

  • (ASP.NET) 转至“属性 >” 网页> 服务器,并确保在使用 Visual Studio 开发服务器下选中启用并继续

  • (ASP.NET WebAPI) 在尝试编辑控制器方法之前,请确保已使用断点停止该方法。

  • (ASP.NET MVC) 有条件地编译 app.UseResponseCompression() 以从 开发环境中排除/70023215/1190540">这里

  • (ASP.NET Core 6) 如果与 RuntimeCompilation 一起使用,请确保 nuget 包已更新到 6.0.9 以上 参考,请注意,不带RuntimeCompilation热重载是新推荐的方法,但如果影响性能,则是一种解决方法。

  • (vs2017) 转到工具 > 选项> 调试取消选中(取消选择)“编辑并继续”。 这实际上与“传统”建议相反(请参阅本文中的其他一些观点)。 它不允许您在正在运行的程序中实际进行更改(即它不会热交换您所做的代码更改) - 它只是允许您编辑代码(即它可以防止烦人的代码更改)消息并“锁定”您的编辑器)。

  • 转到工具> 选项> 调试> 常规并确保未选中要求源文件与原始版本完全匹配

  • 选中启用 Windows 调试堆分配器(仅限本机)[VS Community 2017]

  • 您是否使用 Microsoft Fakes? 它抑制编辑和编辑 继续。

  • 通过在任务管理器中选择结束进程树来终止所有*.vshost.exe实例。 VS 将重新生成正确的实例。

  • 通过调试->删除所有断点删除所有断点

  • 启用并继续存在于工具>中。 选项> 调试菜单以及项目设置中。 请务必检查这两个地方。 编辑& 扩展 Intellitrace 设置不支持继续。

  • 确保项目属性>中的调试信息 构建> 高级> 输出> 调试信息设置为完整

  • 某些插件可能会干扰。 通过禁用/卸载进行检查,然后再次尝试其他解决方案。

  • 如果您没有给予足够的重视,在尝试修复此问题时遇到的错误可能会更改为更容易诊断的其他错误。 例如,包含 lambda 表达式的方法不支持编辑和继续。

  • 确保系统变量 COR_ENABLE_PROFILING 和/或 CORECLR_ENABLE_PROFILING 未设置为 1。 一些分析器在安装时设置此项,并在卸载后保持原样。 打开命令提示符并输入 set 快速检查您的系统是否受到影响,如果是,请删除该变量或将其设置为 0

    • 在 Windows 8 及更高版本中,搜索系统(控制面板)。
    • 点击高级系统设置链接。
    • 点击环境变量
    • 删除 COR_ENABLE_PROFILING 和/或 CORECLR_ENABLE_PROFILING
  • 注意不支持的方案(如问题中所报告)以及不支持的编辑


* 我所说的“您”,是指正在敲击键盘寻找解决方案的页面访问者。


如果此处未列出,请随意编辑此答案以添加您的解决方法!

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 the Optimize Code checkbox in Project Properties->Build

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

  • (ASP.NET MVC) Conditionally compile app.UseResponseCompression() to exclude from Development environment from here.

  • (ASP.NET Core 6) If used with RuntimeCompilation make sure the nuget packages is updated past 6.0.9 Reference, be aware that Hot Reload without RuntimeCompilation is new recommended approach, but a workaround if affects performance.

  • (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 and/or CORECLR_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 and/or CORECLR_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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文