Visual studio 2022 Hot reload issue

Viewed 3109

Today i install VS2022 community Edition and saw a demon on hot reload from youtube. when i try to see how it works then i got a issue.

I have a winform and it has Load event. in load event i initialize a label with value. at runtime i change the value in load event & save the file but change does not reflect onto form UI. what mistake i made there....any idea?

private void Form1_Load(object sender, EventArgs e)
{
    label1.Text = "Hellow";
}

hello spelling is wrong and it is done intentionally. when i run the program the wrong spelling assign to label. after running i change the hellow to hello and save the file but changes does not reflect onto form and wrong spelling was showing there.

please guide me how hot reload works?

thanks

2 Answers

For the the Hot Reload to work, Solutions Configurations must be set to Debug

You should check the target framework of your app. It works for me just like the demo video when I changed the target framework to .NET 6.0.

A summary from the blog post (https://devblogs.microsoft.com/dotnet/update-on-net-hot-reload-progress-and-visual-studio-2022-highlights):

  • When using Visual Studio 2022 and starting your app with the debugger the basic Hot Reload experience works with most types of .NET apps and framework versions, this includes .NET Framework, .NET Core and .NET 5+ (for both C# and VB.NET as applicable). The type of apps that are supported include web (code-behind changes), desktop, mobile, cloud and other project types. The key rule here is if you’re using the debugger assume Hot Reload is available to you and give it a try!

  • When using Visual Studio 2022 but not using the debugger (for example using CTRL-F5 to start the app) Hot Reload is now available even without the debugger when targeting most types of .NET 6 apps. This means that apps not targeting .NET 6 (.NET 5 or below) will not support the “no debugger” scenario and must use the debugger to get Hot Reload support.

  • When using Visual Studio 2022 with a .NET 6 app, the most type of scenarios are supported. This is not limited to simply the “no debugger” scenario mention above, it also includes support for project types such as .NET MAUI and Blazor and more generally editing Razor files and CSS Hot Reload in ASP.NET apps. It also includes other minor optimizations in additional app frameworks. Using both Visual Studio 2022 and updating your apps to .NET 6 will definitively give you the most powerful Hot Reload experience and we hope you will give it a try.

Related