- article
Applies to: visual study
Visual Studio for Mac
visual study code
Starting with Visual Studio 2022, the warm reload experience in Visual Studio is available for managed .NET applications and native C++ applications. Regardless of the type of application you're working on, the purpose of warm reloading is to save as many application restarts as possible between edits, reducing the time you spend waiting for the application to rebuild, restart, and restart to improve your productivity. Navigate to where you were previously in the app, etc.
We do this by allowing you to edit an application's code files and immediately apply code changes to a running application (also known aswarm reload. After applying the changes, run the code again by executing actions in the application itself (or via some kind of timer, etc.) and immediately see the changes. no need to break the app via breakpoints!
Update the current code by reloading
Open the project according to the supported application type. For more information about .NET, see.NET application support.
make sureEnable native code debuggingDisabled in debugger settings or debug startup profile.
Start the application with the attached debuggerF5or ifSupport your application,Ctrl+F5.
Open a C#, C++, or Visual Basic code file that contains some code that can be run again through the user interface of a running application (such as the code behind a button or the view model command) or triggered intermittently by a timer, and Change the password.
Apply code changes withwarm reloadbutton or pressALT+F10.
Supported .NET application frameworks and scripts
- When you use Visual Studio 2022 and start the program with the debugger, the core reload experience works with most .NET application types and framework versions. This support includes the .NET Framework, .NET Core, and .NET 5+ (for C# and Visual Basic). Supported app types include web (code-behind changes), desktop, mobile, cloud, and other project types. The expectation in this case is that if you're using a debugger, assume you can use hot reload and give it a try!
- When using Visual Studio 2022 without the debugger(such as using CTRL-F5 to launch the application), even for most types of .NET 6 applications, reloading is available. This means that applications that do not target .NET 6 (.NET 5 or earlier) do not support the "no debug" scenario and must use a debugger to get reload support.
- Most scenarios are supported when using Visual Studio 2022 with .NET 6 applications.This is not limited to the new "no debugging" feature mentioned above. It also includes other new features such as support for reloading Blazor projects and more generally support for editing Razor files in any ASP.NET Core application and reloading CSS. Using Visual Studio 2022 with applications that target .NET 6 will give you the most powerful hot reload experience.
The table below shows which application types support .NET Hot Reload with a debugger attached (F5) and without a debugger attached (Ctrl+F5), and whether .NET 6 is required for minimal support (eg F5). Ctrl+F5 support always requires .NET 6. The minimum version of Visual Studio that supports the feature is also shown.
Application types | Requires .NET 6 | F5 | Ctrl+F5 |
---|---|---|---|
ASP.NET code behind | No | 16.11 | 17,0 |
ASP.NET Razor (Blazor Server and ASP.NET Core) | And | 17,0 | 17,0 |
ASP.NET Razor (Blazor WASM) | And | 17.1 | 17,0 |
WPF | No | 16.11 | 17,0 |
WinUI3 | No | 16.11 | -- |
form | No | 16.11 | 17,0 |
comfort | No | 16.11 | 17,0 |
.NET MAUI (WinUI 3) | And | 17.1 | -- |
.NET Maui (Android) | And | 17.1 | -- |
.NET Maui (iOS) | And | 17.1 | -- |
.NET MAUI Blazor Hybrid (WinUI 3) | And | 17.1 | -- |
.NET MAUI Blazor Hybrid (Android) | And | 17.1 | -- |
.NET MAUI Blazor Hybrid (iOS) | And | 17.1 | -- |
The type of processing you can do with hot reload is determined by the runtime, not by the method you use to start the application (F5 or Ctrl+F5).
In the following sections, we will expand on the above summary and delve into more detail.
Support for C++ applications
When using Visual Studio 2022 and starting the program with the debugger, you can use the following command to reload a native C++ application while it is running under the debugger (F5)warm reloadbutton. Applications built with CMake and OpenFolder projects also support warm reloading.
This experience is supported by native Editing and Continuity. For supported mods, seeedit and continue.
Visual Studio 2022 with a .NET application when using the debugger
When using Visual Studio 2022 and launching the application through the debugger, reloading works with most application frameworks, including standard application types such as console, Windows Forms (WinForms), WPF, UWP, WinUI 3 (see note) and most types of applications. ASP.NET Web projects (for code-behind editing) include ASP.NET MVC projects, Web API, and even older Web Forms projects. These are examples. Wherever you have .NET and use Visual Studio managed debuggers, you should get basic reload support. This means that even something like Azure Functions works well in this case.
noting
WinUI 3 uses mixed debugging by default and does not support warm reloading. You can enable the reload feature by changing this setting in the project settings, enabling the managed debugger. To enable this feature in your project, modify launchSettings.json and add"native-debug": false
aftercommand name
property.
.NET MAUI applications are supported by Visual Studio 2022 version 17.1 Preview 1.
Visual Studio 2022 with a .NET application without a debugger
Hot reloads work without a debugger when targeting most types of .NET 6 applications, including console, WPF, Windows Forms (WinForms), ASP.NET Core MVC, Web API, and Blazor project types.
This feature is exclusive to .NET 6+. Applications that do not target .NET 6 (.NET 5 or earlier) do not support the "no debug" scenario and must use a debugger to access the reload feature.
Also note that not all project types support the "no debug" scenario. ESPECIALLY:
- UWP apps do not support reloading without a debugger. This is by design and there are currently no plans to improve it.
- Xamarin.Forms apps for iOS and Android do not support .NET fast reload (regardless of whether you launch the app with the debugger), but will continue to support XAML fast reload.
- .NET MAUI applications are only supported by the debugger.
Visual Studio 2022 with .NET 6 applications
If you're also using Visual Studio 2022 and developing apps that target .NET 6, you'll have the most refined and powerful reload experience.
This scene supports:
- Blazor App (Server and WebAssembly (see notes))
- Edit Razor files in Blazor and regular ASP.NET Core websites
- Active CSS reload
- Support for hot reload when the application is running without a debugger (as described in more detail earlier)
If you're targeting .NET 6, you can continue to receive improvements in upcoming Visual Studio 2022 updates, as well as .NET feature bands and major releases.
noting
Hot reload support for Blazor WebAssembly using the Visual Studio debugger is not currently enabled in the first release of Visual Studio 2022 (version 17.0), but is available starting in 17.1. You can still get a warm reload if you start the application through Visual Studio without a debugger or update to version 17.1.
Supported ASP.NET Core scripts
Many ASP.NET scripts support a basic reload experience. The most widely used feature is the ability to modify code files and other .NET class files for most types of web applications. This feature works when you use the Visual Studio debugger and appears wherever Edit and Continue were previously available. For more specific guidance, see.NET Hot Reload support for ASP.NET Core.
For ASP.NET Core developers targeting .NET 6, there are additional features not available in earlier versions of .NET. These features include:
- CSHTML:Editing Razor CSHTML files support several types of editing.
- Browse Update:When debugging, editing a shaver automatically updates the changes in the web browser. This feature was previously only available when the application was launched without a debugger.
- Summary CSS reload:You can change CSS files while the program is running, and the changes are applied to the current program immediately as you type.
- Without a debugger:Hot reload support is available when you use Visual Studio to launch a web application without a debugger (CTRL-F5).
Supported .NET editors
The .NET reload experience is powered byedit and continueMechanism and Roslin.Supported authorsLists the types of modifications currently supported by Roslyn and possible future enhancements.
Unsupported .NET scripts
Unsupported scripts:
- Xamarin.Forms apps do not support .NET hot reload in iOS and Android scenarios. When targeting UWP apps, you get partial support for warm reloading. This is the design and we don't want to make any further improvements. (Note: Xamarin.Forms clients in the latest SDK will continue to use and support XAML fast reloading.)
- .NET MAUI applications are not supported until Visual Studio 2022 version 17.1 Preview 1. As of 17.1 Preview 1, .NET MAUI is supported, but only with the attached debugger.
- Applications built using F# or targeting .NET Native do not support warm reloading.
If you are using Visual Studio without a debugger. NET hot reload is only available for applications targeting .NET 6.
Also, warm reloading is not available in some project configurations:
- If you use the Visual Studio debugger to run your program, but have disabled it
edit and continue
In the settings, warm reloading is not supported. - Version or custom version configurations are not supported. Your project must use a debug build configuration.
- .NET Hot Reload does not support some startup or compilation optimizations. For example, .NET hot reload is not supported if your project's debug profile is configured as follows:
- plumsis enabled for your project. For example if
post cut
Set to True in the debug profile project file. - ready to driveis enabled for your project. For example if
publication ready for viewing
Set to True in the debug profile project file.
- plumsis enabled for your project. For example if
- For WinUI 3 applications, native code debugging is enabled by default (even inStartindstillinger.json), and .NET Hot Reload is not supported when you run mixed-mode debugging this way. So you need to add an explicit setting
native-debug: false
reachStartindstillinger.jsonFor .NET hot reload to work properly.
Configure reload parameters
You can configure the new load by selectingRegulationfromwarm reloadfall down handsome
or opentool>chances>error correction>.NET/C++ Hot Reload.
Hot reload options include:
Enable fast reload and edit while debugging and continue. Enable fast reload on startup with debugger connected (F5).
Enable warm restart on boot without debugging. Enable fast reload (Ctrl+F5) on startup without a debugger attached.
Apply reloading to the file store. Code changes are applied when saving the file.
You can also check if .NET hot reload is available at the project level by modifying the .NET 6 project launchSetting.json and settingactive reload
reachInaccurate
.
Example:
{ "profiles": { "Console": { "commandName": "Project", "hotReloadEnabled": false } }}
warning message
If you see the following dialog, the reload was unable to apply the current changes without a restart. You can choose to rebuild the application and apply the changes (restart) or continue editing. All application state is lost if it is rebuilt. If you keep editing, other changes or fixes may make quick reload work again.
if you chooseyou always rebuilddialog, you will not see the dialog again in the current Visual Studio session, and Visual Studio will automatically rebuild and reload instead of showing the dialog.
noting
In the first release of Visual Studio (version 17.0), the default Edit and Continue dialog still appeared when using fast reload in the debugger. This is a bug that has been fixed starting with version 17.1 Preview 2.
troubleshooting
For ASP.NET Core, if you are using response compression, see the following informationresponse compressionexistsdot net ur
.
See also
Edit and Continue (Visual C#)Edit and Continue (C++)