背景

MAUI版本:preview4
通过VS2019 preview创建了一个MAUI应用程序,设置了MauiApp1.WinUI3为启动项目,在启动时,提示如下错误

System.Reflection.TargetInvocationException:“Exception has been thrown by the target of an invocation.”

COMException: 没有注册类 (0x80040154 (REGDB_E_CLASSNOTREG))

解决

参考https://github.com/dotnet/maui/issues/1127
排查方法:

  1. 安装VS Preview 16.11.0 Preview 1.0。
  2. 安装MAUI Check工具,并通过maui-check命令,检查MAUI环境是否完整且正确。
  3. VS下新建.NET MAUI App项目。
  4. 设置WinUI3 (Package)项目为启动项。
  5. 以“本地计算机”为目标,运行项目。

标签: MAUI, 0x80040154, TargetInvocationException, MauiApp1.WinUI3

添加新评论