I recently upgraded Visual Studio 2019 to install the Project Reunion templates so I can run WinUI3 apps. I followed this guide. I believe I installed all the workloads and components from this list but I may have missed something. I installed the templates and they show up when I try to create a new app.
Here the details of my Visual Studio installation.
Microsoft Visual Studio Professional 2019
Version 16.11.3
VisualStudio.16.Release/16.11.3+31702.278
Microsoft .NET Framework
Version 4.8.04084
When I try to run an app, I get this error message:
System.Reflection.TargetInvocationException HResult=0x80131604 Message=Exception has been thrown by the target of an invocation. Source=System.Private.CoreLib StackTrace: at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& hasNoDefaultCtor) at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean wrapExceptions) at System.Activator.CreateInstanceT at WinRT.WeakLazy`1.get_Value() at Microsoft.UI.Xaml.Application._IApplicationStatics.get_Instance() at Microsoft.UI.Xaml.Application.Start(ApplicationInitializationCallback callback) at App9.Program.Main(String[] args) in C:\Users\chris\source\repos\App9\App9\App9\obj\x64\Debug\net5.0-windows10.0.19041.0\App.g.i.cs:line 26
This exception was originally thrown at this call stack: [External Code]
Inner Exception 1: COMException: Class not registered (0x80040154 (REGDB_E_CLASSNOTREG))
Installed Workloads:
The guide says to install C++ (v142) Universal Windows Platform tools
. I see this in the installer:
I've seen this type of exception being thrown when I've accidentally set the wrong project as the startup project in Visual Studio.
WinUI apps currently have two projects: the main app project and a packaging project (which generates an MSIX). To debug the WinUI app, you need to set the packaging project as the Startup Project.
Going forward, the team are working on merging the two for the most common scenarios. More complex scenarios may still require a packaging project. You can try out the single project using either of these Visual Studio extensions: