Supported Code Changes (C#)
Edit and Continue handles most types of code changes within method bodies. Most changes outside method bodies, and a few changes within method bodies, cannot be applied during debugging, however. To apply those unsupported changes, you must stop debugging and restart with a fresh version of the code.
The following changes cannot be applied to C# code during a debugging session:
Changes to the current statement or any other active statement.
Active statements include any statements, in functions on the call stack, that were called to get to the current statement.
The current statement is marked by a yellow background in the source window. Other active statements are marked by a shaded background and are read-only. These default colors can be changed in the Options dialog box.
Changes to global symbols, including the following:
Adding new types.
Adding methods to a type.
Changing the signature of a type.
Adding fields, events, or properties to a type.
Editing an anonymous method or any method that contains an anonymous method. These methods are marked by a shaded background.
Adding a new anonymous method.
Adding, removing, or changing attributes.
Adding, removing, or changing using directives.
Removing or changing local variables. Adding local variables is allowed.
Adding a foreach, using, or lock around the active statement.
Modifying a method that contains a yield return or yield break statement.
Changing a constructor with a field that is initialized by an anonymous method.
Unsafe Code
Changes to unsafe code have the same limitations as changes to safe code, with one additional restriction:
- Edit and Continue does not support changes to unsafe code that exits within a method that contains the stackalloc operator. This applies only to active methods. When you are debugging, any function currently on the call stack is an active function.
Exceptions
Edit and Continue supports changes to catch, finally,and try blocks, with some exceptions for blocks in active methods, such as methods that are currently on the call stack.
In an active function that is the most recent function on the call stack, Edit and Continue does not support:
Adding a catch or finallyblock around the active statement.
Adding nested exception handlers with nesting levels greater than six.
In an active function that is not the most recent function on the call stack, Edit and Continue does not support:
Adding a catch, finally or tryblock around the active statement.
Adding nested exception handlers with nesting levels greater than six.
Changing code within a tryblock that contains the active statement.
Unsupported Scenarios
Edit and Continue is not available in the following debugging scenarios:
Debugging LINQ code. For more information, see Debugging LINQ.
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 that has Attach to instead of running the application by choosing Start from the Debug menu.
Debugging optimized code.
Debugging an old version of your code after a new version failed to build because of build errors.
See Also
Tasks
How to: Use Edit and Continue (C#)