I get this error message when I try to start my WinUI 3 apps from Visual Studio:
But I already installed the newest .net v8.0.8. I also tried to install the specified v8.0.0 version but it did not help either. The installed runtimes on my PC:
My apps are WindowsAppSDKSelfContained with the following settings in the .csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>x86;x64;ARM64</Platforms>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
<UseRidGraph>true</UseRidGraph>
<UseWinUI>true</UseWinUI>
<EnableMsixTooling>true</EnableMsixTooling>
<WindowsPackageType>None</WindowsPackageType>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
</PropertyGroup>
But interestingly when I start the .exe from the output folder it runs perfectly without this issue for one winui3 app but the other app has the same issue even when started from the .exe file. Both have the same settings in the .csproj files.
The root cause of the problem was probably a Windows App SDK versioning mismatch. Especially when developing unpackaged apps, the version of the Windows App SDK installed on the PC has to match exactly the version of the Windows App SDK NuGet package of the WinUI project, otherwise issues arise. After I updated to a newer version of that NuGet package the issue got resolved.