question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Can't run published WinUI app.

See original GitHub issue

How to reproduce:

Create a new MAUI project (VS 16.11.0 preview 2)

Debug => Runs fine Publish => Running the published app Starts then exits with following error (from event viewer)

Application: MauiApp2.WinUI.exe CoreCLR Version: 6.0.21.30105 .NET Version: 6.0.0-preview.5.21301.5 Description: The process was terminated due to an unhandled exception. Exception Info: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.Runtime.InteropServices.COMException (0x80040154): Class not registered (0x80040154 (REGDB_E_CLASSNOTREG)) at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode) in System.Private.CoreLib.dll:token 0x600467f+0x4 at WinRT.BaseActivationFactory…ctor(String typeNamespace, String typeFullName) in Microsoft.WinUI.dll:token 0x6000023+0x6e at Microsoft.UI.Xaml.Application._IApplicationStatics…ctor() in Microsoft.WinUI.dll:token 0x6014cbd+0x1c at System.RuntimeType.CreateInstanceOfT() in System.Private.CoreLib.dll:token 0x6000645+0x3e — End of inner exception stack trace — at System.RuntimeType.CreateInstanceOfT() in System.Private.CoreLib.dll:token 0x6000645+0x4e at System.Activator.CreateInstanceT in System.Private.CoreLib.dll:token 0x6000963+0x0 at WinRT.WeakLazy`1.get_Value() in Microsoft.WinUI.dll:token 0x6000019+0x20 at Microsoft.UI.Xaml.Application.Start(ApplicationInitializationCallback callback) in Microsoft.WinUI.dll:token 0x6009b84+0x0 at MauiApp2.WinUI.Program.Main(String[] args) in C:\Users\mark\source\repos\MauiApp2\MauiApp2\MauiApp2.WinUI\obj\Release\net6.0-windows10.0.19041\win10-x64\Windows\App.g.i.cs:line 26

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:6
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Steinliiipppcommented, Jul 10, 2021

Same Problem here. I can run the project in Visual Studio 2019 Preview without any problems. But as soon as i build the executable and launch it, i get the same crash report in the windows event viewer.

.NET SDK Version: 6.0.100-preview.5.21302.13 Commit: d6380bcae7

Runtime: OS Name: Windows OS Version: 10.0.19042 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\6.0.100-preview.5.21302.13\

Host (useful for support): Version: 6.0.0-preview.5.21301.5 Commit: ec3e0b276b

.NET SDKs installed: 2.2.203 [C:\Program Files\dotnet\sdk] 3.1.410 [C:\Program Files\dotnet\sdk] 5.0.400-preview.21277.10 [C:\Program Files\dotnet\sdk] 6.0.100-preview.5.21302.13 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.All 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.0-preview.5.21301.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.0-preview.5.21301.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.0-preview.5.21301.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

1reaction
YataoFengcommented, Dec 29, 2021

环境 Microsoft Visual Studio Enterprise 2022 (64 位) - Preview 版本 17.1.0 Preview 1.1 MAUI Perview11

调试 Blazor MAUI 在 VS2022 中运行正常。

发布单文件时,我遇到了问题,怎么解决?

————————————————————————————————————————————— FolderProfile.pubxml

<Project>
  <PropertyGroup>
    <Configuration>Debug</Configuration>
    <Platform>Any CPU</Platform>
    <PublishDir>bin\Release\net6.0-windows\publish\</PublishDir>
    <PublishProtocol>FileSystem</PublishProtocol>
    <TargetFramework>net6.0-windows10.0.19041</TargetFramework>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <SelfContained>true</SelfContained>
    <PublishSingleFile>True</PublishSingleFile>
    <PublishReadyToRun>False</PublishReadyToRun>
    <PublishTrimmed>True</PublishTrimmed>
  </PropertyGroup>
</Project>

————————————————————————————————————————————— 输出

已启动生成…
1>------ 已启动生成: 项目: MauiApp1, 配置: Debug Any CPU ------
1>MauiApp1 -> C:\Users\Yatao Feng\source\repos\MauiApp1\MauiApp1\bin\Debug\net6.0-windows10.0.19041\win10-x64\MauiApp1.dll
2>------ 发布已启动: 项目: MauiApp1, 配置: Debug Any CPU ------
2>正在确定要还原的项目…
2>The RuntimeIdentifier 'win-x64' is invalid.
========== 生成: 成功 1 个,失败 0 个,最新 0 个,跳过 0 个 ==========
========== 发布: 成功 0 个,失败 1 个,跳过 0 个 ==========

————————————————————————————————————————————— 弹窗

发布遇到错误。
发布时遇到错误。我们无法确定错误的原因。有关详细信息,请查看输出日志。

已将诊断日志写入以下位置:
“C:\Users\Yatao Feng\AppData\Local\Temp\tmp36FD.tmp”。 

————————————————————————————————————————————— tmp36FD.tmp

2021/12/29 10:46:28
System.AggregateException: 发生一个或多个错误。 ---> Microsoft.WebTools.Shared.Exceptions.WebToolsException: 发布时遇到错误。我们无法确定错误的原因。有关详细信息,请查看输出日志。
   --- 内部异常堆栈跟踪的结尾 ---
---> (内部异常 #0) Microsoft.WebTools.Shared.Exceptions.WebToolsException: 发布时遇到错误。我们无法确定错误的原因。有关详细信息,请查看输出日志。<---

Microsoft.WebTools.Shared.Exceptions.WebToolsException: 发布时遇到错误。我们无法确定错误的原因。有关详细信息,请查看输出日志。

===================

—————————————————————————————————————————————

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exe published from default WinUI 3/Windows App SDK ...
However, when I publish my app, I get an error message when I run Setup.exe. This states: "Cannot continue. The application is improperly ......
Read more >
WinUI 3 App Runs on Development Machine, Crashes ...
I have a WinUI3/Windows App executable which runs fine on my development machine. After it's signed it can be installed on the development ......
Read more >
WinUI 3, Desktop application error during "Package and ...
I'm working on a WinUI 3 desktop application. During the option of "Package and Publish", I get an error of which I've attached...
Read more >
Packaged, Unpackaged and Self-Contained WinUI 3 Apps ...
Unfortunately if you “publish” your application from Visual Studio, for some reason the executable doesn't run – I'm assuming this is one of...
Read more >
"You must install .NET Desktop Runtime 6.0.4 (x64)" error
When I try running the binaries on a Windows 10 machine, I get the following message box: To run this application, you must...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found