InstallCommandSetsFromFileAsync引发异常“系统找不到指定的文件。 (来自HRESULT的异常:0x80070002)“ [英] InstallCommandSetsFromFileAsync raises exception "The system cannot find the file specified. (Exception from HRESULT: 0x80070002)"

查看:113
本文介绍了InstallCommandSetsFromFileAsync引发异常“系统找不到指定的文件。 (来自HRESULT的异常:0x80070002)“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用启用了语音命令。该命令使用以下代码加载到app构造函数中

My app is voice command enabled. The command is loaded in the app contructor with the following code

await VoiceCommandService.InstallCommandSetsFromFileAsync(new Uri("file://" + Windows.ApplicationModel.Package.Current.InstalledLocation.Path + @"/ToothBrushingTimerVoiceCommands.xml", UriKind.RelativeOrAbsolute));

它在模拟器中运行良好但在真实手机上抛出以下异常。 

It works perfect in the emulator but throws the following exception on real phones. 

系统无法找到指定的文件。 (HRESULT异常:0x80070002)


跟踪:

  在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)

  在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)

  在System.Runtime.CompilerServices.TaskAwaiter.GetResult()

  在BrushingTimer.App。< RegisterVoiceCommandsFile> d__0.MoveNext()

---从抛出异常的上一个位置开始的堆栈追踪结束---

   ;在System.Runtime.CompilerServices.AsyncMethodBuilderCore。< ThrowAsync> b__0(对象状态)



我的语音命令是我发送到市场的xap的一部分所以我认为它也应该在电话上。为语音命令文件内容构建操作。

我希望有人可以帮助我。

I hope someone can help me with this.

推荐答案

您应该使用"ms-appx:///"引用应用程序安装文件夹中的文件。

You should use "ms-appx:///" to reference a file in your application install folder.

ex:

await VoiceCommandService.InstallCommandSetsFromFileAsync(new Uri("ms-appx:///ToothBrushingTimerVoiceCommands.xml"));





这篇关于InstallCommandSetsFromFileAsync引发异常“系统找不到指定的文件。 (来自HRESULT的异常:0x80070002)“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆