c# - Cortana RequestDisambiguationAsync 错误

标签 c# windows-runtime windows-10 win-universal-app

我正在尝试通过为我的应用程序工作的 Cortana 让用户与后台应用程序进行交互。

每当我执行 RequestDisambiguationAsync(response) 时,Cortana 都会说它遇到了错误。但是,它不会在 Visual Studio 中的任何地方中断。

关于可能导致它的原因有什么想法吗?下面是我正在使用的代码:

var userPrompt = new VoiceCommandUserMessage();
string home1 = data.Structures[0].Name;
string home2 = data.Structures[1].Name;
userPrompt.DisplayMessage = "Which one did you want to set to home?";
userPrompt.SpokenMessage = String.Format("Which one did you want to set to home? {0} or {1}?", home1, home2);

var userReprompt = new VoiceCommandUserMessage();
userReprompt.DisplayMessage = "Which one did you want to set to home?";
userReprompt.SpokenMessage = "Which one did you want to set to home?";

var structuresContentTiles = new List<VoiceCommandContentTile>();

var structureTile = new VoiceCommandContentTile();
structureTile.ContentTileType = VoiceCommandContentTileType.TitleWith68x68IconAndText;
structureTile.Title = home1;
structureTile.AppContext = data.Structures[0].Structure_id;
structuresContentTiles.Add(structureTile);

var structureTile2 = new VoiceCommandContentTile();
structureTile2.ContentTileType = VoiceCommandContentTileType.TitleWith68x68IconAndText;
structureTile2.Title = home2;
structureTile.AppContext = data.Structures[1].Structure_id;
structuresContentTiles.Add(structureTile2);

var response = VoiceCommandResponse.CreateResponseForPrompt(userPrompt, userReprompt, structuresContentTiles);

var voiceCommandDisambiguationResult = await voiceServiceConnection.RequestDisambiguationAsync(response);

最佳答案

在某些情况下,当您使用时可能会发生此行为

structureTile.ContentTileType = VoiceCommandContentTileType.TitleWith68x68IconAndText;

但不提供图像。将其更改为 VoiceCommandContentTileType.TitleOnly,或者如果您提供的是 Line1,请使用 VoiceCommandContentTileType.TitleWithText,或提供图像,这应该会阻止失败的发生。

关于c# - Cortana RequestDisambiguationAsync 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31954679/

相关文章:

c# - 如何使用 C# 以编程方式在 OpenFile 对话框中选择文件

c# - 动态参数导致编译器认为方法返回是动态的

javascript - 在 Windows 8 Metro HTML5 应用程序中调整图像大小同时保持其质量?

c# - 在UWP应用程序中直接调用后台任务

c# - protobuf-csharp-port 是否支持 Windows RT?

c - 适用于 Windows 的 Linux 子系统中的线程差异

windows-10 - Windows上的通用标签

c# - 如何使用 EF LINQ 从表中选择所有列和自定义列?

c# - 如何在单元测试中使用 Moq 和 DbFunctions 来防止 NotSupportedException?

c# - 使用 DataGrid 更新访问表时出错