我正在尝试通过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或提供一个Image,这样就可以阻止故障的发生。
关于c# - Cortana RequestDisambiguationAsync错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31954679/