WinUI配置免注册WinRT组件报DEP0700注册失败问题
免注册WinRT组件配置时InProcessServer节点缺失ActivatableClass报错问题
问题现象
配置非打包桌面应用的免注册UWP WinRT组件时,持续收到组件未注册报错,部署阶段触发清单校验失败:
DEP0700: 应用注册失败。[0x80080204] 错误 0xC00CE012: 应用清单校验错误:清单不符合schema规范:第39行第8列,元素'{http://schemas.microsoft.com/appx/manifest/foundation/windows10}InProcessServer'内容不符合DTD/Schema要求,缺少预期的子节点{http://schemas.microsoft.com/appx/manifest/foundation/windows10}ActivatableClass。
检查自动生成的AppxManifest.xml发现,InProcessServer节点下仅配置了组件dll路径,没有自动生成必需的ActivatableClass条目。
已完成的配置
1. 属性表配置
按照官方教程创建Propertysheet.props属性表引入WinRT组件,配置内容如下:
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ImportGroup Label="PropertySheets" /> <PropertyGroup Label="UserMacros" /> <PropertyGroup /> <ItemDefinitionGroup /> <ItemGroup /> <ItemGroup> <Reference Include="C:\Users\User\Solution\x64\Debug\Component\Component.winmd"> <IsWinmdFile>true</IsWinmdFile> </Reference> <ReferenceCopyLocationPaths Include="C:\Users\User\Solution\x64\Debug\Component\Component.dll"> <IsWinmdFile>false</IsWinmdFile> </ReferenceCopyLocationPaths> <!--<Reference Include="C:\Users\User\Solution\x64\Debug\Component2\Component2.winmd"> <IsWinmdFile>true</IsWinmdFile> </Reference> <ReferenceCopyLocationPaths Include="C:\Users\User\Solution\x64\Debug\Component2\Component2.dll"> <IsWinmdFile>false</IsWinmdFile> </ReferenceCopyLocationPaths>--> </ItemGroup> </Project>
编译解决方案后,Component组件的.winmd和.dll文件均可正常复制到主程序DUALITY.exe输出目录,但Component2仅自动复制了winmd文件,因此暂时注释了Component2的相关配置。后续通过属性管理器将该属性表添加到Application项目,添加后可视化添加引用功能被禁用,但引用本身可正常生效。
2. 应用清单配置
当前项目的app.manifest配置如下:
<?xml version="1.0" encoding="utf-8"?> <assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyIdentity version="1.0.0.0" name="Application.app"/> <application xmlns="urn:schemas-microsoft-com:asm.v3"> <windowsSettings> <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware> <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness> </windowsSettings> </application> <file name="Component.dll"> <activatableClass name="Component.SubNamespace.Class" threadingModel="both" xmlns="urn:schemas-microsoft-com:winrt.v1" /> </file> <!--<file name="Component2.dll"> <activatableClass name="Component.PeregrineX12" threadingModel="both" xmlns="urn:schemas-microsoft-com:winrt.v1" /> </file>--> </assembly>
此前已排查过命名空间配置问题,尝试过多种命名空间写法均未解决报错。
自动生成的打包清单内容
编译生成的AppxManifest.xml完整内容如下,可见Extensions节点下的InProcessServer配置确实缺失ActivatableClass:
<?xml version="1.0" encoding="utf-8"?> <Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap rescap build" xmlns:build="http://schemas.microsoft.com/developer/appx/2015/build"> <Identity Name="837f0535-5d07-4290-983b-a49988c57b12" Publisher="CN=User" Version="1.0.0.0" ProcessorArchitecture="x64" /> <Properties> <DisplayName>Application</DisplayName> <PublisherDisplayName>User</PublisherDisplayName> <Logo>Assets\StoreLogo.png</Logo> </Properties> <Dependencies> <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.22000.0" MaxVersionTested="10.0.22000.0" /> <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" /> <PackageDependency Name="Microsoft.WindowsAppRuntime.1.1" MinVersion="1001.524.1918.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" /> <PackageDependency Name="Microsoft.VCLibs.140.00.Debug" MinVersion="14.0.30704.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" /> <PackageDependency Name="Microsoft.VCLibs.140.00.Debug.UWPDesktop" MinVersion="14.0.30704.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" /> </Dependencies> <Resources> <Resource Language="EN-US" /> </Resources> <Applications> <Application Id="App" Executable="Application.exe" EntryPoint="Windows.FullTrustApplication"> <uap:VisualElements DisplayName="Application" Description="DUALITY" BackgroundColor="transparent" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png"> <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" /> <uap:SplashScreen Image="Assets\SplashScreen.png" /> </uap:VisualElements> </Application> </Applications> <Capabilities> <rescap:Capability Name="runFullTrust" /> </Capabilities> <Extensions> <Extension Category="windows.activatableClass.inProcessServer"> <InProcessServer> <Path>Component.dll</Path> </InProcessServer> </Extension> </Extensions> <build:Metadata> <build:Item Name="cl.exe" Version="19.31.31107.0" /> <build:Item Name="OptimizingToolset" Value="None" /> <build:Item Name="TargetRuntime" Value="Native" /> <build:Item Name="Microsoft.UI.Xaml.Markup.Compiler.dll" Version="1.0.0.0" /> <build:Item Name="Microsoft.UniversalCRT.Debug" Version="10.0.22000.0" /> <build:Item Name="makepri.exe" Version="10.0.22621.1 (WinBuild.160101.0800)" /> </build:Metadata> </Package>
正常情况下该ActivatableClass节点应由构建流程自动生成,需要定位自动生成逻辑失效的原因并修复。
内容的提问来源于stack exchange,提问作者user358186
相关产品推荐
相关产品推荐

