Supported code changes (C# and Visual Basic)
The Hot Reload mechanism, previously called Edit and Continue, handles most types of code changes within method bodies. Most changes outside method bodies, and a few changes within method bodies, can't be applied during debugging, however. To apply those unsupported changes, you must stop debugging and restart with a fresh version of the code.
The Edit and Continue mechanism handles most types of code changes within method bodies. Most changes outside method bodies, and a few changes within method bodies, can't be applied during debugging, however. To apply those unsupported changes, you must stop debugging and restart with a fresh version of the code.
Supported changes to code
The following table shows the changes that might be made to C# and Visual Basic code during a debugging session without restarting the session.
Language element or feature | Supported edit operation | Limitations |
---|---|---|
Types | Add methods, fields, constructors, and more | Yes |
Iterators | Add or modify | No |
async/await expressions | Add or modify | Yes |
Dynamic objects | Add or modify | No |
lambda expressions | Add or modify | Yes |
LINQ expressions | Add or modify | Same as lambda expressions |
Generics | Add or modify | Yes |
Language element or feature | Supported edit operation | Limitations |
---|---|---|
Types | Add methods, fields, constructors, and more | Yes |
Iterators | Add or modify | No |
async/await expressions | Add or modify | Yes |
Dynamic objects | Add or modify | No |
lambda expressions | Add or modify | Yes |
LINQ expressions | Add or modify | Same as lambda expressions |
Note
Newer language features such as string interpolation and null-conditional operators are generally supported by Edit and Continue. For the most current information, see the Enc Supported Edits page.
.NET 6+ improvements
Improvements in .NET 6+ and Visual Studio 2022 and later versions include support for more types of edits that go beyond what was originally possible in older versions of Visual Studio. These improvements are available to both Hot Reload and the Edit and Continue experiences.
The .NET 6+ Hot Reload experience is powered by the Edit and Continue mechanism and Roslyn. Supported Edits lists the types of edits currently supported by Roslyn and potential future enhancements.
Unsupported changes to code
The following changes can't be applied to C# and Visual Basic code during a debugging session.
Changes to the current statement or any other active statement.
An active statement is any statement in a function on the call stack that was called to get to the current statement.
The current statement appears on a yellow background in the source window. Other active statements appear on a shaded background and are read-only. These default colors can be changed in the Options dialog box.
Any unsupported changes to code by language element as outlined in the following table.
Language element or feature Unsupported edit operation All code elements Renaming Namespaces Add Namespaces, types, members Delete Interfaces Modify Types Add abstract or virtual member, add override (see details) Types Add destructor Members - Modify a member referencing an embedded interop type
- Modify a static member after it has already been accessed by executing codeMembers (Visual Basic) - Modify a member with On Error or Resume statement
- Modify a member containing an Aggregate, Group By, Simple Join, or Group Join LINQ query clauseMethods - Modify signatures
- Make an abstract method become nonabstract by adding a method body
- Delete method bodyAttributes Add or modify Events or properties Modify a type parameter, base type, delegate type, or return type Operators or indexers Modify a type parameter, base type, delegate type, or return type catch blocks Modify when it contains an active statement try-catch-finally blocks Modify when it contains an active statement using statements Add async methods/lambdas Modify an async method/lambda in a project targeting .NET Framework 4 and lower (see details) Iterators Modify an iterator in a project targeting .NET Framework 4 and earlier (see details) Language element or feature Unsupported edit operation All code elements Renaming Namespaces Add Namespaces, types, members Delete Generics Add or modify Interfaces Modify Types Add abstract or virtual member, add override (see details) Types Add destructor Members - Modify a member referencing an embedded interop type
- Modify a static member after it has already been accessed by executing codeMembers (Visual Basic) - Modify a member with On Error or Resume statement
- Modify a member containing an Aggregate, Group By, Simple Join, or Group Join LINQ query clauseMethods - Modify signatures
- Make an abstract method become nonabstract by adding a method body
- Delete method bodyAttributes Add or modify Events or properties Modify a type parameter, base type, delegate type, or return type Operators or indexers Modify a type parameter, base type, delegate type, or return type catch blocks Modify when it contains an active statement try-catch-finally blocks Modify when it contains an active statement using statements Add async methods/lambdas Modify an async method/lambda in a project targeting .NET Framework 4 and lower (see details) Iterators Modify an iterator in a project targeting .NET Framework 4 and earlier (see details)
Unsafe code
Changes to unsafe code have the same limitations as changes to safe code, with one extra restriction: Edit and Continue doesn't support changes to unsafe code that exits within a method that contains the stackalloc
operator.
Application support
Supported applications include:
- UWP apps in Windows 10 or Windows 11
- x86 and x64 apps that target the .NET Framework 4.6 desktop or later versions (the .NET Framework is a desktop version only)
For .NET 6 and later, editing is supported for the following file types:
- .cshtml
- .razor
Unsupported apps, platforms, and operations
Unsupported applications or platforms include:
- F#
- .NET Native
- Silverlight 5
- Windows 8.1
- Xamarin.Forms (iOS and Android)
For ASP.NET and ASP.NET Core, editing isn't supported for the following file types:
- .aspx
- .ascx
- .aspx
- .ascx
- .cshtml
- .razor
Unsupported scenarios
Edit and Continue isn't available in the following debugging scenarios:
Mixed-mode (native/managed) debugging.
Debugging on Arm64 without targeting .NET 7 or later.
Debugging with the COR_ENABLE_PROFILING environment variable set.
Debugging an application using attach to process (Debug > Attach to Process) instead of running the application by choosing Start from the Debug menu. If you wish to use Edit and Continue when attaching to a process, the COMPLUS_ForceENC environment variable must be set prior to launching the process (
set COMPLUS_ForceENC=1
).Debugging with nondeterministic (for example, time based) assembly versions. If you wish to use Edit and Continue, consider setting the version only in Release (or CI) builds and keep the version in Debug builds constant.
Debugging optimized code.
SQL debugging.
Debugging a dump file.
Debugging an embedded runtime application.
Debugging an old version of your code after a new version failed to build because of build errors.