microsoft / microsoft/microsoft-ui-xaml

Error when running a WinUI Unpackaged app in Visual Studio 2022

Open
#10,171 4 comments 3 reactions 0 assignees View on GitHub
area-Unpackaged bug Crash team-Core
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

Hi,

When I try to run a WInUI app in Visual Studio 2022 Community Version 17.12.0 in "Unpackaged" mode I get the following error:

System.Runtime.InteropServices.COMException
HResult=0x80040154
Message=Class not registered (0x80040154 (REGDB_E_CLASSNOTREG))
Source=System.Private.CoreLib
StackTrace:
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
at WinRT.ActivationFactory.Get(String typeName, Guid iid)
at Microsoft.UI.Xaml.Application.get__objRef_global__Microsoft_UI_Xaml_IApplicationStatics()
at Microsoft.UI.Xaml.Application.Start(ApplicationInitializationCallback callback)
at App4.Program.Main(String[] args) in G:\Data\Users\Ward\Documents\Visual_Studio_Projects\App4\obj\x64\Debug\net8.0-windows10.0.19041.0\win-x64\App.g.i.cs:line 26

This happens if I have it set to either x86 / x64.

The project type I create is: "Blank App, Packaged (WinUI 3 in Desktop)"

Note If I run it as a packaged app it runs without issue.

Thanks
Ward

![Image](https://github.com/user-attachments/assets/caff8d00-001d-4dcb-9c01-cc83cd71425d)

![Image](https://github.com/user-attachments/assets/77381878-6151-4afe-a4d9-e812ed8c353c)

### Steps to reproduce the bug

In Visual Studio 2022 - create a project of type: "Blank App, Packaged (WinUI 3 in Desktop)".

Then set the package type to: (Unpackaged)

### Expected behavior

_No response_

### Screenshots

_No response_

### NuGet package version

None

### Windows version

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure from a Visual Studio 2022 "Blank App, Packaged (WinUI 3 in Desktop)" project after switching it to Unpackaged mode, using the x86 and x64 configurations. Start at App.g.i.cs line 26 and compare the unpackaged and packaged runs; done means the unpackaged app starts without the 0x80040154 Class not registered exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, csharp
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.