3

Before reporting to Microsoft I want to ask here. I have a problem that I cannot see Live Visual Tree of my WinUI 3 application. I cannot even see the in-app toolbar. I can see both in WPF and UWP application, no problems. I have these options for hot reload, that should be fine.

XAML Hot Reload options

enter image description here

I am using VS2022 17.3.1 and Windows App SDK in version 1.1.4. Weird is that it was functioning without problems, but one restart of application just broke that. I also tried adding the ENABLE_XAML_DIAGNOSTICS_SOURCE_INFO to environment variables manually, but no luck there.

It seems that 32-bit WinUI 3 app is working fine, it only affects 64-bit WinUI 3 applications. Even the new and blank ones. Packaged/unpacked type doesn't affect the problem.

I tried uninstall and install VS again, no changes.

benderto
  • 896
  • 11
  • 39
  • Have you tried restarting VS or in a new plain WinUI 3 project? – Andrew KeepCoding Aug 18 '22 at 08:44
  • Yes, I even update it to get the latest version of VS. It seems that 32-bit WinUI 3 app is working fine, it only affects 64-bit WinUI 3 applications. Even the new and blank ones. Packaged/unpacked type doesn't affect the problem. I also updated Windows. – benderto Aug 18 '22 at 08:53
  • BTW, I just updated VS(v17.3.1), WinAppSDK(v1.1.4) and SDK.BuildTools(v10.0.22621.1) and run my WinUI3 app(x64) but the Live Visual Tree shows the components. – Andrew KeepCoding Aug 18 '22 at 12:27
  • Yeah, colleague of mine also has no problems with described situation, so it affects only my development environment. Thanks for trying it out. – benderto Aug 18 '22 at 16:52
  • Same thing happened to me just now. If you have a solution, I'd be happy to know it... – Andreas Hassmann Aug 20 '22 at 10:18

3 Answers3

3

So I did finally find a solution (more of a workaround) to this.

Run following commands in elevated cmd, where you replace WindowsAppRuntime version with version you currently have (for me it is Microsoft.WindowsAppRuntime.1.1_1004.584.2120.0_x64__8wekyb3d8bbwe):

takeown /f "C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.1_1004.584.2120.0_x64__8wekyb3d8bbwe" /r /d y
icacls.exe "C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.1_1004.584.2120.0_x64__8wekyb3d8bbwe" /grant Users:(RD,R,REA,RX) /t

Don't know what it does, but it is working. This solution is taken over from Developer Community

UPDATE: You have to repeat this procedure when you update Windows App SDK to a new version.

Yusuf Tarık Günaydın
  • 3,016
  • 2
  • 27
  • 41
benderto
  • 896
  • 11
  • 39
2

Here is a PowerShell command that loops over all WindowsAppRuntime folders and applies the fixes on @benderto's answer.

Get-ChildItem -Path 'C:\Program Files\WindowsApps\' -Filter 'Microsoft.WindowsAppRuntime*' | Foreach {
  takeown /f "C:\Program Files\WindowsApps\$_" /r /d y
  icacls.exe "C:\Program Files\WindowsApps\$_" /grant "Users:(RD,R,REA,RX)" /t
}

You don't need to restart Visual Studio for this to take effect. Restarting the debugging session is enough.

Yusuf Tarık Günaydın
  • 3,016
  • 2
  • 27
  • 41
1

After lots of reinstallion, 100+?, I came across with this information then problem solved.

It is very frustrating the recent quality of Visual Studio 2022 after 17.2. Each update gets me reinstall loops again, again and again, just because something broken.

This time, MAUI (WinUI 3) XAML Hot Reload won't work. XAML Hot Reload

So I created 3 VMs and installed with different detail of workloads, and tried to figure out "What's wrong". But I failed.

The error seems random. However, I did get some thing strange.

The Hot Reload was "working" after installaion and I left the VM on. After awhile back, I stopped debugging and restarted to debug, the working one became "not working" somehow over time, so I compared two snapshot, one work, one did not. After comparing installion configuration, run with user, run with admin, MAUI App with .net 6.0, MAUI App with template 7.0, both registry, both disk contain (entire C:). I found nothing, all identical as they should be.

Checking Logs: Event Log, AppData\Local\Temp\VSLogs, AppData\Local\Xamarin\Logs\17.0, the Output of VS

However, the Output: debug. Did make me tracing the component binding process, also found nothing.

The One "Not Wotking":
The One "Not Wotking"
The One "Working":
The One "Working"

Huge data but no luck:
Assembly binding log

Windows Policy, no luck: Audit Access Deny

I have to say the error logs are well hidden.

After lots of google thing, I came across with this information then problem solved. It is a Permission problem.

And then I dig a little further, here i found:

VS Output:
WindowsAppRuntime, installed at first run, may be update after

C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.1_1005.616.1651.0_x64__8wekyb3d8bbwe

The list of files that Permissions are different (Not Working vs. Working):

  • CoreMessagingXP.dll
  • dcompi.dll
  • dwmcorei.dll
  • DwmSceneI.dll
  • DWriteCore.dll
  • marshal.dll
  • Microsoft.DirectManipulation.dll
  • Microsoft.Foundation.winmd
  • Microsoft.Graphics.winmd
  • Microsoft.InputStateManager.dll
  • Microsoft.Internal.FrameworkUdk.dll
  • Microsoft.UI.Composition.OSSupport.dll
  • Microsoft.UI.Input.dll
  • Microsoft.UI.Windowing.Core.dll
  • Microsoft.UI.winmd
  • Microsoft.Web.WebView2.Core.dll
  • Microsoft.Web.WebView2.Core.winmd
  • resources.pri
  • WindowsAppRuntime.png
  • WindowsAppSdk.AppxDeploymentExtensions.Desktop.dll
  • wuceffectsi.dll
  • en-GB\Microsoft.ui.xaml.dll.mui
  • en-GB\Microsoft.UI.Xaml.Phone.dll.mui
  • Microsoft.UI.Xaml\Assets\NoiseAsset_256x256_PNG.png

Conclution:

  1. The "Microsoft.WindowsAppRuntime" will get installed on first run and will not get uninstalled with Visual Studio uninstallation.
  2. The "Microsoft.WindowsAppRuntime" may get updated and permission also get changed.
  3. The ACL permission of Microsoft.WindowsAppRuntime folder and files in it may change somehow after some time, same version (Did not go this far to see why).
  4. Manipulate the Permission manually does the trick
  5. Simple Rest (SYSTEM access right is required, PsExec):
psexec64 -i -s cmd.exe /k icacls.exe "C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.1_1005.616.1651.0_x64__8wekyb3d8bbwe\*.*" /reset /t
  1. Minimun Reset (for my case, as soon as this reset done, the hot reload shows up when debug, remember to restart debug):
psexec64 -i -s cmd.exe /k icacls.exe "C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.1_1005.616.1651.0_x64__8wekyb3d8bbwe\Microsoft.Internal.FrameworkUdk.dll" /reset
CH C
  • 11
  • 2