2016-12-28 5 views
0

をインストールすることができません私はマイクロソフトのドキュメントを次のですがここで見つける:コルタナの統合:VCDのXMLファイル

https://msdn.microsoft.com/en-us/cortana/voicecommands/launch-a-foreground-app-with-voice-commands-in-cortana#Install_the_VCD_commands

を私のWindows 10アプリにコルタナの統合を実装します。しかし、私は次のエラーメッセージを取得しています...

を「システムファイルを見つけることができませんが、指定された」ここで私はVCDをインストールしようとしていますどこでOnLaunched方法のための私のコードは...

protected override async void OnLaunched(LaunchActivatedEventArgs e) 
{ 


    Frame rootFrame = Window.Current.Content as Frame; 

    // Do not repeat app initialization when the Window already has content, 
    // just ensure that the window is active 
    if (rootFrame == null) 
    { 
     // Create a Frame to act as the navigation context and navigate to the first page 
     rootFrame = new Frame(); 

     rootFrame.NavigationFailed += OnNavigationFailed; 

     if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) 
     { 
      //TODO: Load state from previously suspended application 
     } 

     // Place the frame in the current Window 
     Window.Current.Content = rootFrame; 
    } 

    if (e.PrelaunchActivated == false) 
    { 
     if (rootFrame.Content == null) 
     { 
      // When the navigation stack isn't restored navigate to the first page, 
      // configuring the new page by passing required information as a navigation 
      // parameter 
      rootFrame.Navigate(typeof(MainPage), e.Arguments); 
     } 
     // Ensure the current window is active 
     Window.Current.Activate(); 
    } 

    try 
    { 
     //StorageFile vcdStorageFile = await Package.Current.InstalledLocation.GetFileAsync("VoiceCommandDefinitions.xml"); 
     //await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcdStorageFile); 

     var storageFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///VoiceCommandDefinitions.xml")); 
     await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(storageFile); 

    } 
    catch (Exception) 
    { 
     throw; 
    } 
} 

私は自分のプロジェクトのルートにあるVCDファイルを持っており、上にリンクされたドキュメントの指示に従ってファイルをコピーするように設定しています。

また、「VoiceCommandDefinitions.xml」という名前のVCDファイルもあります。

<?xml version="1.0" encoding="utf-8" ?> 
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2"> 
    <CommandSet xml:lang="en-gb" Name="VoiceCommands_en-gb"> 
    <AppName>Hero Explorer</AppName> 
    <Example>Refresh the characters list</Example> 

    <Command Name="RefreshCharactersLIst"> 
     <Example>Refresh the characters list</Example> 
     <ListenFor>Refresh [the] [characters] list</ListenFor> 
     <Feedback>Refreshing the characters list</Feedback> 
     <Navigate/> 
    </Command> 

    </CommandSet> 
</VoiceCommands> 

私は間違っていますか?

答えて

1

自分のコードを自分の側でテストしましたが、コードに問題はありません。エラー

によると

最も考えられる理由は、あなたのファイルの場所またはファイル名と間違って何かである「ファイルを見つけることができないシステムは、指定されました」。まず、ファイル名が定義されているコードと同じであることを確認してください。 VCDファイル用の新しいxmlファイルを作成した後、定義した名前はVoiceCommandDefinitions.xmlではなくVoiceCommandDefinitionsでなければなりません。作成したときにファイルには既に接尾辞が付きます。

次の画像が示すように、VCDファイルが実際にプロジェクトのルートにあることを確認してください。最後に

enter image description here

、またファイルのBuild Actionプロパティは、プロジェクトの実行時に見つけることができるファイルを保証するプロジェクト内のコンテンツであることを確認してください( - >プロパティ右のファイルをクリックしてください)。

enter image description here

+0

こんにちは@Sunteen!お返事をありがとうございます。残念ながら、あなたの指示に従った後、私はまだ同じエラーに直面しています。スクリーンショットをご覧ください:http://imgur.com/a/gEx27何が欠けていますか? –

+0

@SamDHarrisあなたはそのコード行に壊れ目を置いて、その行によって例外がスローされるのを見るためのスクリーンショットがありますか? –

+0

@Sunteenもう一度おねがいします。あなたがここで何を求めているのかよくわからない:http://imgur.com/a/sOcapは、vcdStorageFile変数内に保持されている情報のスクリーンショットです。希望このヘルプ:) –

関連する問題