Редактиране

Споделяне чрез


Configure Edit and Continue (C#, VB, C++)

You can disable or enable Hot Reload, previously called Edit and Continue, in the Visual Studio Options dialog box at design time. Hot Reload works only in debug builds. For more information, see Hot Reload.

Edit and Continue is a time-saving feature that enables you to make changes to your source code while your program is in break mode. When you resume execution of the program by choosing an execution command like Continue or Step, Edit and Continue automatically applies the code changes with some limitations. This allows you to make changes to your code during a debugging session, instead of having to stop, recompile your entire program, and restart the debugging session.

You can disable or enable Edit and Continue in the Visual Studio Options dialog box at design time. Edit and Continue works only in debug builds. For more information, see Edit and Continue.

For native C++, Edit and Continue requires using the /INCREMENTAL option. For more information about feature requirements in C++, see this blog post and Edit and Continue (C++).

Enable and configure Hot Reload

You can configure Hot Reload by selecting Settings from the Hot Reload drop-down button.

Screenshot of configuring Hot Reload.

Or, open Tools > Options > Debugging > .NET/C++ Hot Reload.

Note

If IntelliTrace is enabled and you collect both IntelliTrace events and call information, Edit and Continue is disabled. For more information, see IntelliTrace.

The settings for Hot Reload include:

  • Enable Hot Reload and Edit and Continue when debugging. Enables Hot Reload when starting with the debugger attached (F5).

  • Enable Hot Reload when starting without debugging. Enables Hot Reload when starting without the debugger attached (Ctrl+F5).

  • Apply Hot Reload on File Save. Applies code changes when you save the file.

  • Logging Verbosity. Filters amount of information displayed in the Hot Reload Output window.

Screenshot of settings for .NET Hot Reload.

For .NET Hot Reload, you also can control whether Hot Reload is available at the project level by modifying your .NET 6+ project's launchSetting.json file and setting hotReloadEnabled to false.

Example:

{
  "profiles": {
    "Console": {
      "commandName": "Project",
      "hotReloadEnabled": false
    }
  }
}

For C++, you can set additional options by opening Tools > Options > Debugging > General. Make sure Enable Hot Reload is selected, and set the other options:

  • Apply changes on continue (Native only)

    If selected, Visual Studio automatically compiles and applies code changes when you continue debugging from a break state. Otherwise, you can choose to apply changes using Debug > Apply Code Changes.

  • Warn about stale code (Native only)

    If selected, gives warnings about stale code.

Enable or disable Edit and Continue

  1. If you're in a debugging session, stop debugging (Debug > Stop Debugging or Shift+F5).

  2. In Tools > Options > (or Debug > Options) > Debugging > General, select Edit and Continue in the right pane.

    Note

    If IntelliTrace is enabled and you collect both IntelliTrace events and call information, Edit and Continue is disabled. For more information, see IntelliTrace.

  3. For C++ code, make sure Enable Native Edit and Continue is selected, and set the other options:

    • Apply changes on continue (Native only)

      If selected, Visual Studio automatically compiles and applies code changes when you continue debugging from a break state. Otherwise, you can choose to apply changes using Debug > Apply Code Changes.

    • Warn about stale code (Native only)

      If selected, gives warnings about stale code.

  4. Select OK.

Stop code changes

While Hot Reload is in the process of applying code changes, you can stop the operation.

While Edit and Continue is in the process of applying code changes, you can stop the operation.

Caution

Stopping code changes in managed code can produce unexpected results. Applying changes to managed code is normally a quick process, so there is seldom a need to stop code changes in managed code.

To stop applying code changes:

  • Choose Stop Applying Code Changes from the Debug menu.

    This menu item is visible only when code changes are being applied.

    If you choose this option, none of the code changes are committed.