【问题标题】:Windows Runtime activatable class in Windows 10Windows 10 中的 Windows 运行时可激活类
【发布时间】: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


【解决方案1】:

您将 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>

【讨论】:

  • 我的扩展在应用程序部分。这就是导致错误的原因。我不知道文件中有两个扩展元素的位置,并错误地将其放置在那里。谢谢!
猜你喜欢
  • 2018-06-20
  • 1970-01-01
  • 2019-01-13
  • 1970-01-01
  • 2020-08-12
  • 2019-04-17
  • 2020-11-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多