maui icon indicating copy to clipboard operation
maui copied to clipboard

XAML Hot Reload not working running MAUI app on Windows Machine

Open vsfeedback opened this issue 5 years ago • 11 comments

This issue has been moved from a ticket on Developer Community.


! [image.png] (https://aka.ms/dc/image?name=B1515664df46945f59725e8befb796773637711123691104432_20211029-095247-image.png&tid=1515664df46945f59725e8befb796773637711123691104432)


Original Comments

Feedback Bot on 11/1/2021, 00:04 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Ken Annable on 11/1/2021, 04:17 AM:

In the step #8 above I indicated pressing F5 when the DLL load exception occurs. I was able to fix this issue by uninstalling VS 2022 and all SDKs, Frameworks, and Runtimes using the “Apps”->“Apps & features” view in Settings. Then manually cleaning up directories in “Program Files”, “Program Files (x86)”, “ProgramData”, and “Users\[myusername]”. Next I ran DiskCleanup, rebooted, and reinstalled VS Community 2022 Preview 7. Performing these steps corrected the DLL load exception but did NOT fix the XAML Hot Reload issue in this ticket.


Original Solutions

(no solutions)

vsfeedback avatar Nov 03 '21 00:11 vsfeedback

I'm experiencing the same issue.

I tried uninstalling and searching my c drive for anything that mentioned "visual studio" and deleted everything. I even went through the registry and deleted a bunch of keys before rebooting and re-installing. When re-installing I only checked components relevant to maui, still no luck.

Hot Reload doesn't work at all, doesn't matter what settings I have enabled, or if the app is running elevated.

ninbura avatar Dec 18 '21 10:12 ninbura

Same problem with Windows Machine.

chaoyebugao avatar Dec 19 '21 03:12 chaoyebugao

Faced the same problem (for all simulators (android, windows)). Code changes were picked up correctly, but not for XAML.

SergVorontsov avatar Dec 21 '21 17:12 SergVorontsov

Same here. No hot reload for any platform deployment.
[3:50:16 PM] (maui) .NET6 Project references MAUI. [3:54:44 PM] (maui) .NET6 Project references MAUI. [3:54:44 PM] (maui) Starting Hot Reload Session... [3:54:45 PM] XAML Hot Reload initializing... [3:54:48 PM] (maui) Failed to initialize the HotReload.Maui Agent TAP [3:54:48 PM] (maui) Caught exception in SetupAgent at 102: System.TypeLoadException: Could not load type of field 'Xamarin.HotReload.Xaml.VisualTreeService.VisualTree.ApplicationWrapper:dispatcher' (0) due to: Could not resolve type with token 01000045 from typeref (expected class 'Microsoft.Maui.Controls.IDispatcher' in assembly 'Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') assembly:Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:Microsoft.Maui.Controls.IDispatcher member:(null) at Xamarin.HotReload.Xaml.VisualTreeService.DiagnosticVisualTreeService..ctor(ILogger logger) in D:\a\_work\1\s\HotReload\Source\Xamarin.HotReload.Xaml\VisualTreeService\DiagnosticVisualTreeService.cs:line 28 at Microsoft.Maui.Controls.HotReload.Forms.MauiAgent.SetupAgent(IServiceProvider provider) in D:\a\_work\1\s\HotReload\Source\Microsoft.Maui.Controls.HotReload.Forms\MauiAgent.cs:line 95 at Xamarin.HotReload.Xaml.VisualTreeService.DiagnosticVisualTreeService..ctor(ILogger logger) in D:\a\_work\1\s\HotReload\Source\Xamarin.HotReload.Xaml\VisualTreeService\DiagnosticVisualTreeService.cs:line 28 at Microsoft.Maui.Controls.HotReload.Forms.MauiAgent.SetupAgent(IServiceProvider provider) in D:\a\_work\1\s\HotReload\Source\Microsoft.Maui.Controls.HotReload.Forms\MauiAgent.cs:line 95 [3:54:51 PM] (maui) Caught exception in InitAgents at 134: System.AggregateException: One or more errors occurred. (Could not load type of field 'Xamarin.HotReload.Xaml.VisualTreeService.VisualTree.ApplicationWrapper:dispatcher' (0) due to: Could not resolve type with token 01000045 from typeref (expected class 'Microsoft.Maui.Controls.IDispatcher' in assembly 'Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') assembly:Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:Microsoft.Maui.Controls.IDispatcher member:(null)) ---> System.TypeLoadException: Could not load type of field 'Xamarin.HotReload.Xaml.VisualTreeService.VisualTree.ApplicationWrapper:dispatcher' (0) due to: Could not resolve type with token 01000045 from typeref (expected class 'Microsoft.Maui.Controls.IDispatcher' in assembly 'Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') assembly:Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:Microsoft.Maui.Controls.IDispatcher member:(null) at Xamarin.HotReload.Xaml.VisualTreeService.DiagnosticVisualTreeService..ctor(ILogger logger) in D:\a\_work\1\s\HotReload\Source\Xamarin.HotReload.Xaml\VisualTreeService\DiagnosticVisualTreeService.cs:line 28 at Microsoft.Maui.Controls.HotReload.Forms.MauiAgent.SetupAgent(IServiceProvider provider) in D:\a\_work\1\s\HotReload\Source\Microsoft.Maui.Controls.HotReload.Forms\MauiAgent.cs:line 103 at Microsoft.Maui.Controls.HotReload.Forms.MauiAgent.VisualTreeChanged(Object sender, VisualTreeChangeEventArgs e) in D:\a\_work\1\s\HotReload\Source\Microsoft.Maui.Controls.HotReload.Forms\MauiAgent.cs:line 65 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at Xamarin.HotReload.HotReloadAgent.<>c__DisplayClass31_1.<InitAgents>b__2(Task t) in D:\a\_work\1\s\HotReload\Source\Xamarin.HotReload.Agent\HotReloadAgent.cs:line 149 at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at Xamarin.HotReload.HotReloadAgent.<>c__DisplayClass31_1.<InitAgents>b__2(Task t) in D:\a\_work\1\s\HotReload\Source\Xamarin.HotReload.Agent\HotReloadAgent.cs:line 149 [3:54:51 PM] (maui) HotReload: Initialized Agent. [3:54:58 PM] Caught exception in AgentStatusChangedHandler at 313: System.Exception: One or more errors occurred. (Could not load type of field 'Xamarin.HotReload.Xaml.VisualTreeService.VisualTree.ApplicationWrapper:dispatcher' (0) due to: Could not resolve type with token 01000045 from typeref (expected class 'Microsoft.Maui.Controls.IDispatcher' in assembly 'Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') assembly:Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:Microsoft.Maui.Controls.IDispatcher member:(null)) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject) [3:54:58 PM] XAML Hot Reload encountered a problem and failed to start. Use Help -> Report a Problem if the issues persists. [3:54:58 PM] Stopping All Hot Reload sessions due to Failed ... [3:54:58 PM] (maui) Stopping a Hot Reload session due to Failed ... [3:54:58 PM] Stopped Hot Reload session.

brendanalexdr avatar Dec 21 '21 21:12 brendanalexdr

Facing same issue. Hot reload is not working for any platform. When I deployed default MAUI project to Android, hot reload did not work. (did a clean vs install, bud did not help)

[10:04:25 AM] (MauiApp21) .NET6 Project references MAUI. [10:04:25 AM] (MauiApp21) Starting Hot Reload Session... [10:04:26 AM] XAML Hot Reload initializing... [10:04:25 AM] (MauiApp21) Failed to initialize the HotReload.Maui Agent TAP [10:04:25 AM] (MauiApp21) Caught exception in SetupAgent at 102: System.TypeLoadException: Could not load type of field 'Xamarin.HotReload.Xaml.VisualTreeService.VisualTree.ApplicationWrapper:dispatcher' (0) due to: Could not resolve type with token 01000045 from typeref (expected class 'Microsoft.Maui.Controls.IDispatcher' in assembly 'Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') assembly:Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:Microsoft.Maui.Controls.IDispatcher member:(null) at Xamarin.HotReload.Xaml.VisualTreeService.DiagnosticVisualTreeService..ctor(ILogger logger) in D:\a_work\1\s\HotReload\Source\Xamarin.HotReload.Xaml\VisualTreeService\DiagnosticVisualTreeService.cs:line 28 at Microsoft.Maui.Controls.HotReload.Forms.MauiAgent.SetupAgent(IServiceProvider provider) in D:\a_work\1\s\HotReload\Source\Microsoft.Maui.Controls.HotReload.Forms\MauiAgent.cs:line 95 at Xamarin.HotReload.Xaml.VisualTreeService.DiagnosticVisualTreeService..ctor(ILogger logger) in D:\a_work\1\s\HotReload\Source\Xamarin.HotReload.Xaml\VisualTreeService\DiagnosticVisualTreeService.cs:line 28 at Microsoft.Maui.Controls.HotReload.Forms.MauiAgent.SetupAgent(IServiceProvider provider) in D:\a_work\1\s\HotReload\Source\Microsoft.Maui.Controls.HotReload.Forms\MauiAgent.cs:line 95 [10:04:26 AM] (MauiApp21) Caught exception in InitAgents at 134: System.AggregateException: One or more errors occurred. (Could not load type of field 'Xamarin.HotReload.Xaml.VisualTreeService.VisualTree.ApplicationWrapper:dispatcher' (0) due to: Could not resolve type with token 01000045 from typeref (expected class 'Microsoft.Maui.Controls.IDispatcher' in assembly 'Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') assembly:Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:Microsoft.Maui.Controls.IDispatcher member:(null)) ---> System.TypeLoadException: Could not load type of field 'Xamarin.HotReload.Xaml.VisualTreeService.VisualTree.ApplicationWrapper:dispatcher' (0) due to: Could not resolve type with token 01000045 from typeref (expected class 'Microsoft.Maui.Controls.IDispatcher' in assembly 'Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') assembly:Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:Microsoft.Maui.Controls.IDispatcher member:(null) at Xamarin.HotReload.Xaml.VisualTreeService.DiagnosticVisualTreeService..ctor(ILogger logger) in D:\a_work\1\s\HotReload\Source\Xamarin.HotReload.Xaml\VisualTreeService\DiagnosticVisualTreeService.cs:line 28 at Microsoft.Maui.Controls.HotReload.Forms.MauiAgent.SetupAgent(IServiceProvider provider) in D:\a_work\1\s\HotReload\Source\Microsoft.Maui.Controls.HotReload.Forms\MauiAgent.cs:line 103 at Microsoft.Maui.Controls.HotReload.Forms.MauiAgent.VisualTreeChanged(Object sender, VisualTreeChangeEventArgs e) in D:\a_work\1\s\HotReload\Source\Microsoft.Maui.Controls.HotReload.Forms\MauiAgent.cs:line 65 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at Xamarin.HotReload.HotReloadAgent.<>c__DisplayClass31_1.b__2(Task t) in D:\a_work\1\s\HotReload\Source\Xamarin.HotReload.Agent\HotReloadAgent.cs:line 149 at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at Xamarin.HotReload.HotReloadAgent.<>c__DisplayClass31_1.b__2(Task t) in D:\a_work\1\s\HotReload\Source\Xamarin.HotReload.Agent\HotReloadAgent.cs:line 149 [10:04:26 AM] (MauiApp21) HotReload: Initialized Agent. [10:04:33 AM] Caught exception in AgentStatusChangedHandler at 313: System.Exception: One or more errors occurred. (Could not load type of field 'Xamarin.HotReload.Xaml.VisualTreeService.VisualTree.ApplicationWrapper:dispatcher' (0) due to: Could not resolve type with token 01000045 from typeref (expected class 'Microsoft.Maui.Controls.IDispatcher' in assembly 'Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') assembly:Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:Microsoft.Maui.Controls.IDispatcher member:(null)) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject) [10:04:33 AM] XAML Hot Reload encountered a problem and failed to start. Use Help -> Report a Problem if the issues persists. [10:04:33 AM] Stopping All Hot Reload sessions due to Failed ... [10:04:33 AM] (MauiApp21) Stopping a Hot Reload session due to Failed ... [10:04:33 AM] Stopped Hot Reload session.

omiimo avatar Dec 26 '21 09:12 omiimo

Updated to Visual Studio 2022 Preview 1.1. Hot reload still broken for all platforms.

brendanalexdr avatar Dec 27 '21 17:12 brendanalexdr

After update to VS Version 17.1.0 Preview 2.0 all works property.

SergVorontsov avatar Jan 09 '22 13:01 SergVorontsov

Issue is fixed with VS Preview 2.0 update.

omiimo avatar Jan 09 '22 15:01 omiimo

Just trying MAUI, and I'm using VS 17.1.0 Preview 5.0, and it's not working at all. I'm debugging, and the hot reload button isn't greyed out - but when I click it, nothing happens. I've tried using both the Android emulator, or just building as a Windows app.

dracan avatar Feb 05 '22 21:02 dracan

Sorry, seems to have now magically started working! Didn't change anything.

dracan avatar Feb 05 '22 22:02 dracan

This issue was originally tied to a mismatch between versions of MAUI and XAML Hot Reload. There were underlying changes in MAUIs API that broke XAML Hot Reload if you happened to upgrade before that shipped with Visual Studio.

That was addressed in an earlier VS release, it shouldn't be an issue now for this specific case.

drasticactions avatar Apr 15 '22 20:04 drasticactions