Cannot install VCD file UWP installCommandDefinitionsFromStorageFileAsync

142 views Asked by At

I integrating Cortana to my app(UWP with Winjs) but when i try to install the VCD file i got that error:

Status is 'error', but getResults did not return an error

main.js (the code is wrapped on activated handler event of application):

wap.current.installedLocation.getFileAsync("Commands.xml").then(function (file) {
    return voiceCommandManager.installCommandDefinitionsFromStorageFileAsync(file);
}, function (er) {
    console.error('error file Commands.xml', er);
}).then(function () {
    var language = window.navigator.userLanguage || window.navigator.language;

    var commandSetName = "BibleCommandSet_" + language.toLowerCase();
    if (voiceCommandManager.installedCommandDefinitions.hasKey(commandSetName)) {
        var vcd = voiceCommandManager.installedCommandDefinitions.lookup(commandSetName);
    } else {
        console.log('VCD not installed yet?');
    }
}, function (ee) {
    console.error("installCommandDefinitionsFromStorageFileAsync error", ee);
});

Commands.xml:

<?xml version="1.0" encoding="utf-8" ?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2">
    <CommandSet xml:lang="en-us" Name="BibleCommandSet_en-us">
        <AppName> Bible </AppName>
        <Example> Go to genesis 1,9 </Example>
        <Command Name="goToQuote">
            <Example> Go to genesis 1,9 </Example>
            <ListenFor RequireAppName="BeforeOrAfterPhrase"> show {book} {number}</ListenFor>
            <ListenFor RequireAppName="BeforeOrAfterPhrase"> show {book} {number}{number}</ListenFor>
            ...
            <ListenFor RequireAppName="BeforeOrAfterPhrase"> open {book} {number}{number},{number}{number}</ListenFor>
            <Feedback> Ok i'm opening {book} </Feedback>
            <Navigate/>
        </Command>
    </CommandSet>

Fixed: in another line of the file i have another commandSet and i've did call a PhraseList "book" but the real name was "libro"

1

There are 1 answers

1
Sunteen Wu On BEST ANSWER

I integrating Cortana to my app(UWP with Winjs) but when i try to install the VCD file i got that error:Status is 'error', but getResults did not return an error

This is because there are something wrong with your VCD file - Command.xml. Since the error is occurred by the VCD file not code itself so you didn't get the error details.

The special character {} in VCD file contains the value of the Label attribute for the PhraseList or PhraseTopic to reference. Used within a ListenFor or Feedback element. A PhraseList or PhraseTopic reference in a Feedback element must match a corresponding reference in a ListenFor element in the same command.

Although PhraseList or PhraseTopic is Optional child for CommandSet, but you defined {book} and {name} for ListenFor and Feedback elements in your VCD file, which need corresponding PhraseList with value of Label attribute is name/book .

I updated the VCD file based on you and now the code can run successfully.

<?xml version="1.0" encoding="utf-8" ?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2">
  <CommandSet xml:lang="en-us" Name="BibleCommandSet_en-us">
    <AppName> Bible </AppName>
    <Example> Go to genesis 1,9 </Example>
    <Command Name="goToQuote">
      <Example> Go to genesis 1,9 </Example>
      <ListenFor RequireAppName="BeforeOrAfterPhrase"> show {book}</ListenFor>
      <ListenFor RequireAppName="BeforeOrAfterPhrase"> show {book} {number}{number}</ListenFor> 
      <ListenFor RequireAppName="BeforeOrAfterPhrase"> open {book} {number}{number},{number}{number}</ListenFor>
      <Feedback> Ok i'm opening {book} </Feedback>
      <Navigate/>
    </Command>
    <PhraseList Label="book">
      <Item>London</Item>
      <Item>Las Vegas</Item>
      <Item>Melbourne</Item>
      <Item>Yosemite National Park</Item>
    </PhraseList>
    <PhraseList Label="number">
      <Item>2</Item>
      <Item>3</Item>
      <Item>4</Item>
      <Item>5</Item>
    </PhraseList>
  </CommandSet>
</VoiceCommands>

More details about VCD file please reference this document.