Share via


Supported Code Changes (C#) 

This topic applies to:

Visual Studio Edition

Visual Basic

C#

C++

J#

Express

No

Yes

No

No

Standard

No

Yes

No

No

Pro/Team

No

Yes

No

No

Edit and Continue handles most types of code changes within method bodies. Most changes outside of 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:

    • 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 changes to attributes.

  • Adding, removing, or changes to 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 containing 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 containing the stackalloc operator. This applies only to active methods. For more information, see Active Statements.

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 finally block 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 try block around the active statement.

    • Adding nested exception handlers with nesting levels greater than six.

    • Changing code within a try block that contains the active statement.

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.

See Also

Tasks

How to: Use Edit and Continue (C#)

Reference

Edit and Continue (Visual C#)

Other Resources

Edit and Continue Errors and Warnings (C#)