【发布时间】:2015-11-09 02:43:27
【问题描述】:
我在尝试为 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。
【问题讨论】:
-
那么,如果是 C#,为什么要标记问题 C++?
-
当我尝试这个时效果很好。您是手动输入而不是让 MSBuild 自动生成它吗?然后你需要显示完整的清单。
-
对不起,博。该应用程序本身是 C#。 Windows 运行时组件是 C++。汉斯,如果我引用该项目,它也对我有用。我的 NuGet 包缺少一个步骤。我通过手动将其放入 appxmanifest 进行试验是解决此问题的一部分。我把完整的文件放在这里gist.github.com/langboost/2f32eff6b042e172804d。
标签: c++ windows-runtime visual-studio-2015 win-universal-app windows-10