0
我在尝试更新我的UWP(Windows 10)应用程序的短语列表,但不是我没有理由为此而发生'灾难性故障'。SetPhraseListAsync - 灾难性故障
我注册柯塔娜像这样在App.xaml.cs
StorageFile vcdStorageFile = await Package.Current.InstalledLocation.GetFileAsync(@"VoiceCommandDefinition.xml");
await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcdStorageFile);
Debug.WriteLine("Cortana loaded");
然后我打开我的数据(这是一个鸟巢恒温器客户端,所以我加载恒温器和结构)。之后,我尝试更新短语列表。
string thermostatsStrings = "";
string structureStrings = "";
VoiceCommandDefinition commandSetEnUs;
if (VoiceCommandDefinitionManager.InstalledCommandDefinitions.TryGetValue("Nest_en-us", out commandSetEnUs))
{
try
{
List<Nest.Thermostat> thermostats = GetAllThermostats();
if (thermostats != null)
{
thermostatsStrings = String.Join(", ", thermostats);
List<String> names = thermostats.Select(thermostat => thermostat.name).ToList();
await commandSetEnUs.SetPhraseListAsync("nest", names);
}
}
catch (Exception ex)
{
Crashes.Log("Helpers - UpdatePhraseListThermostat", true, ex.Message +
Environment.NewLine + "Thermostats: " + thermostatsStrings +
Environment.NewLine + "Structures: " + structureStrings);
}
try
{
List<Nest.Structure> structures = GetAllStructures();
if (structures != null)
{
structureStrings = String.Join(", ", structures);
List<String> names = structures.Select(structure => structure.name).ToList();
await commandSetEnUs.SetPhraseListAsync("place", names);
}
}
catch (Exception ex)
{
Crashes.Log("Helpers - UpdatePhraseListStructure", true, ex.Message +
Environment.NewLine + "Thermostats: " + thermostatsStrings +
Environment.NewLine + "Structures: " + structureStrings);
}
}
我的VCD文件看起来像这样
<?xml version="1.0" encoding="utf-8" ?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2">
<CommandSet xml:lang="en-US" Name="Nest_en-us">
<AppName> Nest </AppName>
<Example> Open Nest </Example>
<Command Name="RequestTemp">
<Example>Nest, what is the current temperature </Example>
<ListenFor> What is [the] {nest} temperature </ListenFor>
<ListenFor> What is [the] temperature in the {nest} </ListenFor>
<ListenFor> What is [the] [current] temperature </ListenFor>
<Feedback> Getting the temperature </Feedback>
<VoiceCommandService Target="NestCommandService"/>
</Command>
<Command Name="SetHome">
<Example> Nest, I'm coming home </Example>
<ListenFor> Set {place} to home </ListenFor>
<ListenFor> I am on my way to {place} </ListenFor>
<ListenFor> I am coming home </ListenFor>
<ListenFor> I am home </ListenFor>
<ListenFor> set [status] to home </ListenFor>
<ListenFor> set [state] to home </ListenFor>
<ListenFor> set [mode] to home </ListenFor>
<ListenFor> I am back </ListenFor>
<ListenFor> I am on my way [home] </ListenFor>
<Feedback> Setting mode to home </Feedback>
<VoiceCommandService Target="NestCommandService"/>
</Command>
<PhraseList Label="nest">
</PhraseList>
<PhraseList Label="place">
</PhraseList>
</CommandSet>
</VoiceCommands>
我建在错误记录在我的应用程序(METROLOG),这是它的日志:
2|2016-02-03T15:39:14.0034437+00:00|TRACE|2|Crashes|Helpers - UpdatePhraseListThermostat
Catastrophic failure
Catastrophic failure
Thermostats: Living Room
Structures:
3|2016-02-03T16:03:32.2687198+00:00|TRACE|2|Crashes|Helpers - UpdatePhraseListStructure
Catastrophic failure
Catastrophic failure
Thermostats: Living Room
Structures: Home