Using Edit and Continue in Visual Studio 2022 with .NET 6+ C# Projects
Enable and use Edit and Continue in Visual Studio 2022 with .NET 6+ C# projects to modify code during debugging without restarting. Covers prerequisites, supported edits, verification steps, and recovery when EnC fails.
31 Mar 2026, 11:28 UTC

Problem and Takeaway
Restarting a debug session after every code change wastes time, especially when iterating on logic inside a long-running loop or a complex workflow. Edit and Continue (EnC) lets you modify C# method bodies while the debugger is paused in break mode, then resume execution with the new code applied—no process restart required. This guide covers enabling EnC, applying changes safely, verifying they took effect, and recovering when the debugger rejects an edit.
Prerequisites
- Visual Studio 2022 17.0 or later with the .NET 6 SDK installed (or newer SDK for .NET 7/8/9 targets).
- Project targeting .NET 6 or later (SDK-style
.csproj). - Build configuration set to Debug (not Release). EnC does not work with optimized code.
- Enable the feature:
Tools > Options > Debugging > General→ check Enable Edit and Continue and Enable Edit and Continue for C#. - Ensure
<DebugType>portable</DebugType>orembeddedis present in the project file (default for SDK-style projects).
Permissions: No elevated rights needed; all settings are per-user in the IDE.
Supported vs. Unsupported Edits
EnC works at the method-body level. The table below summarizes what you can change without restarting.
| Supported | Unsupported (requires restart) |
|---|---|
| Statement additions, deletions, reordering | Adding or removing methods, properties, fields |
| Local variable declarations and initializers | Changing class hierarchy (base class, interfaces) |
| Lambda and anonymous method bodies | Modifying generic type parameters or constraints |
| LINQ query expression changes | Editing async methods, iterator blocks (yield return) |
Control-flow alterations (if, switch, loops) within current method | Altering referenced assembly metadata (signatures, attributes) |
| Modifying variable values via Locals/Watch windows | Concurrent edits across many files exceeding transaction limits |
Procedure: Apply a Code Change During Debugging
- Open the solution and set a breakpoint inside a method you want to tweak (e.g., inside a
foreachloop). - Start debugging with F5. Execution pauses at the breakpoint.
- While paused, edit the method body—change a string literal, add a
Console.WriteLine, adjust a calculation, or insert a new local variable. - Press F5 (Continue) or F10/F11 (Step Over/Into). Visual Studio compiles the incremental change and patches the running process.
- Observe the updated behavior immediately in the console output or variable watches.
Concrete Verification Example
Create a new .NET 6 Console App to confirm EnC works in your environment:
// Program.cs
using System;
var items = new[] { "alpha", "beta", "gamma" };
foreach (var item in items)
{
Console.WriteLine($"Processing: {item}"); // ← set breakpoint here
}
- Set a breakpoint on the
Console.WriteLineline. - Press F5. When the breakpoint hits, change the interpolated string to
$"Updated: {item.ToUpper()}". - Press F5 to continue.
- Check the Output window (Debug pane): you should see
Applying code changes...followed by the new outputUpdated: ALPHA,Updated: BETA,Updated: GAMMAwithout the process restarting.
Expected checks:
- Output window shows
Applying code changes...and no error dialog appears. - Call stack updates to reflect the new IL (visible in the Call Stack window).
- Modified logic executes on the next step/iteration.
Diagnosing EnC Failures
When an edit is not supported, Visual Studio displays the Edit and Continue not supported dialog with two options:
- Restart Debugging (Ctrl+Shift+F5) — rebuilds and restarts the session.
- Stop Debugging (Shift+F5) — ends the session; you manually restart.
Common failure reasons and quick checks:
| Symptom | Likely Cause | Check |
|---|---|---|
| Dialog appears immediately after edit | Edit falls in unsupported category (async, yield, signature change) | Review the unsupported list above; revert to a supported change. |
Applying code changes... hangs or times out | Large solution, many projects, or incremental compilation bottleneck | Apply edits one file at a time; consider disabling "Require source files to exactly match the original version" (see below). |
| No output, but breakpoint not hit again | Source/PDB mismatch (edited file differs from built assembly) | Ensure <DebugType>portable</DebugType>; rebuild if source was edited outside VS. |
| EnC menu items grayed out | Debugging Release build, mixed-mode, or attached to remote process | Switch to Debug config; disable mixed-mode in project debug properties; for remote, ensure msvsmon matches VS version. |
Recovery Options
If EnC fails, you have three practical paths:
- Revert and continue: Undo the unsupported edit (Ctrl+Z), press F5 to resume, then re-apply a supported change at the next breakpoint.
- Restart debugging: Press Ctrl+Shift+F5 to rebuild and restart the session with all current source changes.
- Stop and re-run: Press Shift+F5, then F5—useful if the process state is corrupted.
Risk note: Restarting loses in-memory state (local variables, heap objects). Plan edits to minimize restarts.
Advanced Configuration
In Tools > Options > Debugging > General, the option Require source files to exactly match the original version is enabled by default. Disabling it allows EnC to apply changes even if the source file on disk differs from the version used to build the current PDB (e.g., you edited the file in another editor while debugging).
Use with caution: Mismatched sources can cause the debugger to show incorrect line numbers or apply changes to the wrong IL offset. Enable only when you understand the risk and need to edit stale files.
Performance Considerations
- EnC incurs a brief pause (typically 1–5 seconds) for incremental compilation and metadata update.
- Large solutions with many projects may take longer; the Output window shows progress.
- Applying changes to multiple files in one break session increases transaction size and failure probability. Apply incrementally: edit one method, continue, then edit the next at the following breakpoint.
Limitations Summary
- No EnC for Release/optimized builds, mixed-mode debugging (managed + native), or remote attached processes without matching
msvsmon. - Async/iterator methods are unsupported because the compiler generates state machines; editing them would require rewriting the state machine structure.
- Generic signature changes alter metadata layout—requires full rebuild.
- .NET Framework projects using the legacy debugger cannot use EnC; requires .NET Core 3.1+ / .NET 5+ with the modern debugger.
- Concurrent edits across many files may hit the EnC transaction limit; the dialog will prompt for restart.
Quick Verification Checklist
- ✅
Tools > Options > Debugging > General: both EnC checkboxes checked. - ✅ Project targets .NET 6+ (check
<TargetFramework>net6.0</TargetFramework>). - ✅ Build configuration is Debug.
- ✅
<DebugType>portable</DebugType>present in.csproj. - ✅ Test with the console example above—new output appears without process restart.
- ✅ Output window shows
Applying code changes...on each successful edit.
If all checks pass, EnC is operational. Use it to tighten the inner loop: edit, continue, verify—repeat.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.