需要帮助加载Cortana VCD文件使用C ++ DirectX / XAML

时间:2015-07-31 15:57:34

标签: c++ windows-10 cortana

我将Cortana添加到DirectX / XAML Windwos 10游戏中。我能找到的每个例子都是用C#而不是C ++给出的。通常情况下这不是一个问题,但显然我没有在C ++中正确实现它,需要一些帮助。

这段代码的目的是加载Cortana用于我的应用程序相关语音命令的VCD文件。我已经使用标准示例创建了VCD文件。

这是我在C ++中实现时遇到的特定C#代码:

var storageFile = 
  await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(
    new Uri("ms-appx:///myvcdfile.xml"));
await 
  Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinitionManager.
    InstallCommandDefinitionFromStorageFileAsync(storageFile);

我尝试的C ++实现是:

Uri^ uri = ref new Uri("ms-appx:///myvcdfile.xml");
    create_task(StorageFile::GetFileFromApplicationUriAsync(uri)).then([](task<StorageFile^> t) {
        StorageFile^ sfile = t.get();
        Windows::ApplicationModel::VoiceCommands::VoiceCommandDefinitionManager::InstallCommandDefinitionsFromStorageFileAsync(sfile);
    });

当我运行它时,不会抛出任何可见错误(没有立即崩溃)但在输出窗口中抛出以下异常:

Exception thrown at 0x76473E28 (KernelBase.dll) in darksong.exe: 0x40080201: WinRT originate error (parameters: 0x8000000B, 0x00000040, 0x018BE280).
Exception thrown at 0x76473E28 (KernelBase.dll) in darksong.exe: 0x00000005: Access is denied.
Exception thrown at 0x76473E28 (KernelBase.dll) in darksong.exe: 0x000006D9: There are no more endpoints available from the endpoint mapper.
Exception thrown at 0x76473E28 (KernelBase.dll) in darksong.exe: 0x000006D9: There are no more endpoints available from the endpoint mapper.
Exception thrown at 0x76473E28 (KernelBase.dll) in darksong.exe: 0x40080201: WinRT originate error (parameters: 0x80004005, 0x00000013, 0x0EEAF160).

&#34;访问被拒绝&#34;错误让我觉得打开文件本身存在一些问题,虽然如果我故意输入一个无效的文件名,那就是一个完全不同的错误,它会崩溃,所以我知道它找到了文件,但实际上可能有一些问题访问它?

此外,即使我排除&#34; InstallCommandDefinitionsFromStorageFileAsync()&#34; line仍然抛出异常。

感谢任何帮助,提前谢谢!

1 个答案:

答案 0 :(得分:0)

您的xml文件中肯定存在错误(如果您在命令中设置了使用PhraseList的项目,但您忘记了xml中的PhraseList节点)