You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

.NET10 Preview7 MAUI应用Windows启动报错:类未注册(REGDB_E_CLASSNOTREG)

问题

将.NET8 MAUI应用升级至.NET10 Preview7版本后,Android、iOS、MacCatalyst平台均可正常启动,但Windows平台启动时崩溃,报错如下:

bin/Release/net10.0-windows10.0.19041.0/win-x64/Foobar.exe
Unhandled exception. System.Runtime.InteropServices.COMException (0x80040154): Class not registered (0x80040154 (REGDB_E_CLASSNOTREG))
   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 Foobar.WinUI.Program.Main(String[] args) in C:\Foobar\obj\Release\net10.0-windows10.0.19041.0\win-x64\Platforms\Windows\App.g.i.cs:line 25

Process finished with exit code -532,462,766.

对应的项目.csproj文件内容:

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>net10.0-windows10.0.19041.0</TargetFramework>
        
<!--        <TargetFrameworks>net10.0-android;net10.0-ios;net10.0-maccatalyst</TargetFrameworks>-->
<!--        <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net10.0-windows10.0.19041.0</TargetFrameworks>-->

        <!-- Note for MacCatalyst:
        The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
        When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
        The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated;
        either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
        <!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->

        <Nullable>enable</Nullable>
        <OutputType>Exe</OutputType>
        <RootNamespace>MauiApp1</RootNamespace>
        
        <UseMaui>true</UseMaui>
        <SingleProject>true</SingleProject>
        <ImplicitUsings>enable</ImplicitUsings>

        <!-- Display name -->
        <ApplicationTitle>MauiApp1</ApplicationTitle>

        <!-- App Identifier -->
        <ApplicationId>com.companyname.mauiapp1</ApplicationId>

        <!-- Versions -->
        <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
        <ApplicationVersion>1</ApplicationVersion>

        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
        <TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
    </PropertyGroup>

    <ItemGroup>
        <!-- App Icon -->
        <MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4"/>

        <!-- Splash Screen -->
        <MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128"/>

        <!-- Images -->
        <MauiImage Include="Resources\Images\*"/>
        <MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185"/>

        <!-- Custom Fonts -->
        <MauiFont Include="Resources\Fonts\*"/>

        <!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
        <MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)"/>
    </ItemGroup>

    <ItemGroup>
        <PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)"/>
        <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="10.0.0-preview.7.25380.108"/>
    </ItemGroup>

</Project>

请问该异常的原因是什么?

异常原因分析

这个REGDB_E_CLASSNOTREG类未注册错误,核心是Windows运行时无法找到Microsoft.UI.Xaml相关的COM组件注册信息,结合.NET10 Preview7的升级场景,主要有以下几种可能:

  • MSIX打包缺失或运行时依赖未部署:.NET MAUI Windows应用依赖WinUI 3,部分WinUI组件需要通过MSIX包完成COM类注册。如果直接运行未打包的Release版exe,或者打包过程中遗漏了WinUI相关依赖,就会触发组件未注册问题。
  • 目标架构不匹配:项目编译的是win-x64,若当前Windows系统是Arm64架构,或者开发环境中Arm64版本的WinUI运行时未正确安装,跨架构调用时会找不到对应的注册类。
  • 预览版SDK兼容性问题:.NET10 Preview7作为预览版,可能存在WinUI组件注册逻辑的bug;或者升级时未清理旧的.NET8构建缓存,导致生成的Windows平台代码引用了未正确注册的组件。
  • 项目配置问题:当前csproj直接指定单一Windows目标框架,注释掉了多框架配置,可能导致构建过程中未引入Windows平台所需的WinUI注册相关MSBuild任务,缺失必要的注册步骤。

内容的提问来源于stack exchange,提问作者XDS

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 09:34:59