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

Need help loading Cortana VCD file on using C++ DirectX/XAML

本文关键字:c++ DirectX XAML 文件 帮助 加载 Cortana VCD      更新时间:2023-10-16

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

这段代码的目的是加载一个VCD文件,Cortana使用它来执行我的应用程序相关的语音命令。我已经使用标准示例创建了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).

"访问被拒绝"错误让我认为有一些问题打开文件本身,虽然如果我故意输入一个无效的文件名,这是一个完全不同的错误崩溃,所以我知道它正在寻找文件,但也许是有一些问题实际上访问它?

另外,即使我排除了"InstallCommandDefinitionsFromStorageFileAsync()"行,异常仍然被抛出。

任何帮助都是感激的,提前感谢!

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