So I'm trying to integrate Cortana in my Universal Windows app using Background task, because I need to build conversation with Cortana.
I was following samples from here
The sample above is using IBackgroundTask to build conversation and disambiguous trip name matching in AdventureWorksVoiceCommandService
So I'm trying to do the same on a really basic sample:
using Windows.ApplicationModel.Background;
namespace AdventureWorks.VoiceCommands
{
public sealed class TestBgService : IBackgroundTask
{
public async void Run(IBackgroundTaskInstance taskInstance)
{
var someVar = taskInstance;
}
}
}
And I updated Package manifest in this way:
<Extensions>
<uap:Extension Category="windows.appService" EntryPoint="AdventureWorks.VoiceCommands.TestBgService">
<uap:AppService Name="TestBgService" />
</uap:Extension>
</Extensions>
And My VCD file contains following:
<Command Name="heyHowLetsGo">
<Example> Hey How Lets Go </Example>
<ListenFor RequireAppName="BeforeOrAfterPhrase">Hey How Lets Go</ListenFor>
<VoiceCommandService Target="TestBgService"/>
</Command>
Running that in AdventureWorks smaple app works just fine(randomly actually, but id does not gives me the error), running the same freaking code in my Universal Windows App when asking Cortana 1-to-1 matched string she always says:
Something went wrong. Try again later
So I assume she does recognizes the command pattern ("Hey How Lets Go"), but some freaking reason she's not able to lunch or run BackgroundTask
The biggest point of frustration is that THERE"S NO FREAKING WAY TO DEBUG CORTANA MESSAGES!!
If I want to know WHAT EXACTLY WENT WRONG -> there's no way for me to do that.
The only possible Output that I was able to get from that thing, when the error occurs is this:
Exception thrown at 0x00007FFC15401F28 in SearchUI.exe: Microsoft C++ exception: wil::ResultException at memory location 0x0000007DF1CFD180.
Exception thrown at 0x00007FFC15401F28 in SearchUI.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
Exception thrown at 0x00007FFC15401F28 in SearchUI.exe: Microsoft C++ exception: Js::JavascriptExceptionObject at memory location 0x0000007DFB9F7DC0.
Please, If anyone has any ideas, experience with that peace of software -> don't pass by without answering. I'm sitting on this thing for more than a day now without any movement.
And yes -> I added the Project with BackgroundTask as reference in startup project -> did not helped
UPDATE1:
So I managed to run a test BackgroundTask by copying the exact VoiceCommandService project from sample app in to my App and adding that (and it is important) as a Reference (Click on your startup project, In toolBar in header got to Project -> Add Reference -> add your project there )
adding it as Project Dependencies or Reference Path -> has 0 effect (*it's sooo Microsoft, sorry)
- My testService in another linked to startup project as Reference still gives same shitty response from awesome Cortana
UPDATE2:
Ok, so I managed to force her to start talking to my tasks!!
- In order to have those BackgroundTask's working you need to have them in separate project
- That project MUST be included as Reference in your Statup Project
- That project MUST be of type: Windows Runtime Component
- Your BackgroundTask MUST NOT contain constructor -> otherwise cortana will bail on it. Do your initialization and other stuff through Run() method
This can be considered as SOLVED.