Supported Code Changes (C#)
Collapse the table of content
Expand the table of content

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.

  • Changing the signature of a type.

  • Adding an anonymous method that captures a variable that hasn’t been captured before.

  • Adding, removing, or changing attributes.

  • Adding, removing, or changing using directives.

  • Adding a foreach, using, or lock around the active statement.

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.

Edit and Continue supports changes to catch and finally blocks, except that adding a catch or finally block around the active statement is not allowed.

Edit and Continue is not available in the following debugging scenarios:

  • Debugging LINQ code in certain circumstances. For more information, see Debugging LINQ.

    • Capturing a variable that hasn’t been captured before.

    • Changing the type of query expression (e.g., select a => select new { A = a };)

    • Removing a where that contains an active statement.

    • Removing a let that contains an active statement.

    • Removing a join that contains an active statement.

    • Removing an orderby that contains an active statement.

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

© 2015 Microsoft