【发布时间】:2015-07-31 15:57:34
【问题描述】:
我正在将 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).
“访问被拒绝”错误让我认为打开文件本身存在一些问题,尽管如果我故意输入无效的文件名,这是一个完全不同的崩溃错误,所以我知道它正在查找文件,但可能有一些实际访问它有问题吗?
另外,即使我排除了“InstallCommandDefinitionsFromStorageFileAsync()”行,仍然会抛出异常。
任何帮助表示赞赏,在此先感谢!
【问题讨论】:
标签: c++ windows-10 cortana