gpt4 book ai didi

c++ - Windows 10 中的 Windows 运行时可激活类

转载 作者:行者123 更新时间:2023-11-30 05:39:53 24 4
gpt4 key购买 nike

当我尝试为 WinRT 注册可激活类时遇到错误。这是在 Windows 10 上的 Visual Studio 2015 中的 C# 通用应用程序 (UAP) 中。

以前,您可以像这样在 Package.appxmanifest 文件中注册可激活类:

<Extension Category="windows.activatableClass.inProcessServer">
<InProcessServer>
<Path>myCode.dll</Path>
<ActivatableClass ActivatableClassId="myNS.MyNativeClass" ThreadingModel="both" />
</InProcessServer>
</Extension>

但是 Visual Studio 不喜欢这样。它违反了 UAP 项目的 appxmanifest 文件的架构:

Validation error. error C00CE169: App manifest validation error: The app manifest must be valid as per schema: Line 42, Column 20, Reason: 'windows.activatableClass.inProcessServer' violates enumeration constraint of 'windows.backgroundTasks windows.preInstalledConfigTask windows.updateTask windows.restrictedLaunch'. The attribute 'Category' with value 'windows.activatableClass.inProcessServer' failed to parse.  TextSecure  C:\Users\123\Documents\GitHubVisualStudio\MyProj\MyProj\bin\x86\Debug\AppxManifest.xml  

那么如何使用 UAP 项目中的 Windows 运行时组件呢?如果不注册它,您会得到一个 TypeLoadException。

最佳答案

您将 Extensions 元素放在了 Application 元素还是 Package 元素中的什么位置?如果将它放在 Application 元素中,则预计会出现此错误。您应该放入 Package 元素中。

例如:

<?xml version="1.0" encoding="utf-8"?>

<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
IgnorableNamespaces="uap mp">
<Capabilities>
<Capability Name="internetClient" />
</Capabilities>
<Extensions>
<Extension Category="windows.activatableClass.inProcessServer">
<InProcessServer>
<Path>yourdll.dll</Path>
</InProcessServer>
</Extension>
</Extensions>
</Package>

关于c++ - Windows 10 中的 Windows 运行时可激活类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32033843/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com