locked
Lumia SensorCoreSDK in combination with background task not working RRS feed

  • Question

  • As a followup to this thread: https://social.msdn.microsoft.com/Forums/windowsapps/en-US/a6425c4d-2ceb-4fcb-a06c-e5fe6d93f7a4/sensorcore-sdk-steps-example-app-not-working?forum=wpdevelop

    I am explaining my test results with the SensorCore SDK 1.0.3.263, which causes major problems in the current release and is not useable.
    To make this simple to reproduce, I am doing all the tests with the public available steps example application.

    Test environment: Visual Studio 2013, Update 4
    Test application: Steps example from http://developer.nokia.com/resources/library/Lumia/sensorcore-sdk/samples.html#toc_Steps
    Test devices: Nokia Lumia 630 and Nokia Lumia 1520 with Cyan update.
    Build configuration: Debug/ARM

    After opening the solution in VS2013, the references to the Lumia SensorCoreSDK are missing => a simple "rebuild all" solves the problem => the current version of the SensorCore nuget packages are downloaded and referenced automatically.

    The automatically referenced LumiaCoreSDK packages are: 
    .\steps-1.1\packages\LumiaSensorCoreSDK.1.0.3.263\build\wp81\\..\..\lib\portable-wpa81+wp81\ARM\Lumia.Sense.winmd
    .\steps-1.1\packages\LumiaSensorCoreSDKTesting.1.0.3.263\build\wp81\\..\..\lib\portable-wpa81+wp81\ARM\Lumia.Sense.Testing.winmd

    Start app with debuggin on the device directly in Visual Studio.

    Unhandled Exception: Requested Windows Runtime type 'Lumia.Sense.StepCounter' is not registered.

    This problem is discussed and solved in the thread https://social.msdn.microsoft.com/Forums/windowsapps/en-US/a6425c4d-2ceb-4fcb-a06c-e5fe6d93f7a4/sensorcore-sdk-steps-example-app-not-working?forum=wpdevelop

    So I added the required Extensions to the "Package.appxmanifest" file (after the applications element), in the Steps-Project.

    Rebuild Solution.
    Set Breaktpoint to "if (!await StepCounter.IsSupportedAsync())" in StepsEngine.cs, Ln. 243

    Start app in Visual Studio in Debug mode with deploment to device.

    => Code with messagebox that the device does not support motion data is excuted. (StepsEngine.cs, Ln. 245)
    Messagebox is shown and app exits.

    Note: 
    Motion data and location are enabled on the device.
    When the app is installed from the store, it works (!).

    I tried this a few times, also in Release-Mode and without Debugger attached.
    The result was always the same: Messagebox that the sensors are not supported by the device.

    Update: Problem is not related to the version of the SensorCore SDK but to the referenced background task, see postings below.
    • Edited by HannesBiri Sunday, December 7, 2014 11:48 AM Updated problem description
    Wednesday, December 3, 2014 7:19 PM

All replies

  • Maybe you can submit a bug request to microsoft.
    Thursday, December 4, 2014 8:26 AM
  • Since the SensorCoreSDK is (in my opinion) not a MS product like Visual Studio or Office, how should I send a bug report? Creating a separate thread for this issue was suggested by Alan from MSDN community support so i hope, this is how it works. :)
    Thursday, December 4, 2014 9:56 AM
  • After some more testing with the 0.9 version of the SensorCore SDK I found out that it does not work too.

    So i did some more tests with the Nokia "Steps" exampe app, Version 1.1 from http://developer.nokia.com/resources/library/Lumia/sensorcore-sdk/samples.html#toc_Steps
    Test devices: Lumia 630, Lumia 1520 with cyan update
    The app use the latest LumiaSensorCoreSDK 1.0.3.263.
    Required entries in the Package.appxmanifest file (Extensions and Capabilities) are present.

    The official Steps-example app always fails, which means the call to 'StepCounter.IsSupportedAsync()' in StepsEngine.cs, Ln. 243 returns false.
    If I stop at this position at a breakpoint and set the program execution to Ln. 251 so the app continues it throws an exception:

    Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
    when calling: _stepCounter = await StepCounter.GetDefaultAsync()

    I used "JustDecompile" to check the metadata file for SensorCore.dll and checked that all classes that exist in the "Lumia.Sense" namespace are present in the Package.appxmanifest - they are.

    Running out of ideals I created my own, very simple test-app, which simply shows the number of steps read from the SensorSDK. It's a windows phone runtime app, uses LumiaSensorCoreSDK 1.0.3.263 and only shows the number of currently reported steps on the screen.
    Package.appxmanifest contains the same extensions as the steps example app.

    Result: IT WORKS!
    This simple test app always worked, when deployed to the device (> 5 times).

    Next steps: see what's different in the steps example app and my "simple test app".

    First: Remove the registration of the background task agent from the steps-example app.
    Result: No change, steps-example still not working

    Second: Removed the project reference to the "BackgroundTasks" assembly in the steps-example app.
    => app runs!
    Now the call to 'if (!await StepCounter.IsSupportedAsync())' is working.

    Re-added assembly reference to "BackgroundTask" in the steps-eample => app is not working again.
    removed reference: working. :)

    I tried the "reverse" thing: Adding a background task to my "simple test application".
    I followed this example: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh977055.aspx

    My simple test app only references the background task and 'Package.appxmanifest' contains an entry in in the declarations for it.
    (System event, timer, Entry point: BackgroundTask.ExampleBackgroundTask)

    Test: Now my simple test app also fails to run.
    Call to 'if (!await StepCounter.IsSupportedAsync() || !await ActivityMonitor.IsSupportedAsync())' returns false.

    Next step: removed the declaration from the 'Package.appxmanifest' so the background task assembly is only references, but not used in any way.
    Test: call fails, so only referencing the background task assembly causes the app to fail.

    Removed the reference to the background task component: App works again!

    Test result: simply referencing a background task WinRT component causes the query for phone sensors to fail.

    Idea: try changing the output type of the background task from "WinRT component" to "class library" in my simple test-app.
    Result: Is is working now.

    Next step: Changed the output type of the background task assembly in the steps-example app to "class library" too.
    Result: App is working

    Fianlly changed the output type...of my "real app" background task to "class library".
    Result: my "real app" now works too! :)

    Possible Solution?
    No, see posting below - now the app works, but the background task does not. When it is called, the app quits.



    • Edited by HannesBiri Sunday, December 7, 2014 11:52 AM Updated problem description
    Friday, December 5, 2014 9:43 AM
  • UPDATE:

    While the main app is running successfully, when the type of the background task is changed to "class library" (or completely removed), the background task itself is NOT. :(

    When execution of the background task is triggered, the application quits.
    So it seems that the background task needs to be a WinRT component...which does not work too, as described above.

    This means: I can get my app to work but it cannot use a live tile....which is very bad. :(

    ...and very strange too since using a background task should have nothing to do with using the SensorCoreSDK of course.

    I hope, MS support can reproduce and fix this issue since it's easy to reproduce with the steps-example app.

    If more information is required from my side, please let me know.

    best regards,
    Hannes




    • Edited by HannesBiri Friday, December 5, 2014 1:59 PM
    Friday, December 5, 2014 1:33 PM
  • Hi MS Support/Forum moderators,

    is there any way to submit an error report for this issue, like it's possible for open source projects?
    At the moment I stopped developing my app because of this issue.

    best regards,
    Hannes

    Tuesday, December 9, 2014 6:03 PM
  • I also have the same problem. It is related to Update 4 of VS.
    Thursday, December 18, 2014 9:06 AM
  • Hi,

    to test this, I also installed the "Steps" app from the marketplace, which also has a live tile.
    @steelspace: can you try this too?

    link: http://www.windowsphone.com/de-at/store/app/steps-lumia-sensorcore-sdk-sample/1851cd52-7192-49b2-b5c6-49a95880295f

    It has a live tile, which is not updated too. :(
    Can someone from MS please also check this?

    best regards,
    Hannes

    Thursday, December 18, 2014 9:26 AM
  • Response from SensorCore engineering:

    It seems that VS2013 Update 4 removes the ActivatableClass entries from genereted appxmanifest.xml if there is any background task referenced in the project. Only classes with no public default constructor is removed.

    It will be studied how to fix this. But if someone wants to get it working already now following can be added manually to Package.appxmanifest as a last entry inside <Package> tags:

    <Extensions>

        <Extension Category="windows.activatableClass.inProcessServer">

          <InProcessServer>

            <Path>Lumia.Sense.Testing.dll</Path>

            <ActivatableClass ActivatableClassId="Lumia.Sense.Testing.StepCounterSimulator" ThreadingModel="both" />

            <ActivatableClass ActivatableClassId="Lumia.Sense.Testing.SenseRecorder" ThreadingModel="both" />

            <ActivatableClass ActivatableClassId="Lumia.Sense.Testing.ActivityMonitorSimulator" ThreadingModel="both" />

            <ActivatableClass ActivatableClassId="Lumia.Sense.Testing.SenseRecording" ThreadingModel="both" />

            <ActivatableClass ActivatableClassId="Lumia.Sense.Testing.TrackPointMonitorSimulator" ThreadingModel="both" />

            <ActivatableClass ActivatableClassId="Lumia.Sense.Testing.PlaceMonitorSimulator" ThreadingModel="both" />

          </InProcessServer>

        </Extension>

        <Extension Category="windows.activatableClass.inProcessServer">

          <InProcessServer>

            <Path>Lumia.Sense.dll</Path>

            <ActivatableClass ActivatableClassId="Lumia.Sense.Place" ThreadingModel="both" />

            <ActivatableClass ActivatableClassId="Lumia.Sense.StepCounter" ThreadingModel="both" />

            <ActivatableClass ActivatableClassId="Lumia.Sense.SenseHelper" ThreadingModel="both" />

            <ActivatableClass ActivatableClassId="Lumia.Sense.ActivityMonitor" ThreadingModel="both" />

            <ActivatableClass ActivatableClassId="Lumia.Sense.SenseTrigger" ThreadingModel="both" />

            <ActivatableClass ActivatableClassId="Lumia.Sense.ActivityMonitorReading" ThreadingModel="both" />

            <ActivatableClass ActivatableClassId="Lumia.Sense.StepCount" ThreadingModel="both" />

            <ActivatableClass ActivatableClassId="Lumia.Sense.PlaceMonitor" ThreadingModel="both" />

            <ActivatableClass ActivatableClassId="Lumia.Sense.TrackPointMonitor" ThreadingModel="both" />

            <ActivatableClass ActivatableClassId="Lumia.Sense.TrackPoint" ThreadingModel="both" />

            <ActivatableClass ActivatableClassId="Lumia.Sense.StepCounterReading" ThreadingModel="both" />

          </InProcessServer>

        </Extension>

        <Extension Category="windows.activatableClass.inProcessServer">

          <InProcessServer>

            <Path>Lumia.Internal.HMBClient.dll</Path>

            <ActivatableClass ActivatableClassId="Lumia.Internal.HMBClient.HMBMessage" ThreadingModel="both" />

            <ActivatableClass ActivatableClassId="Lumia.Internal.HMBClient.HMBServiceClient" ThreadingModel="both" />

            <ActivatableClass ActivatableClassId="Lumia.Internal.HMBClient.HMBMessageEventArgs" ThreadingModel="both" />

          </InProcessServer>

        </Extension>

      </Extensions>

     

    Monday, December 29, 2014 4:34 PM
  • Many thanks for your answer, I will test this and reply, if it works.

    best regards,
    Hannes

    Wednesday, January 7, 2015 7:10 PM
  • Great!

    I added

    <Extension Category="windows.activatableClass.inProcessServer">

          <InProcessServer>

            <Path>Lumia.Internal.HMBClient.dll</Path>

            <ActivatableClass ActivatableClassId="Lumia.Internal.HMBClient.HMBMessage"ThreadingModel="both" />

            <ActivatableClassActivatableClassId="Lumia.Internal.HMBClient.HMBServiceClient" ThreadingModel="both" />

            <ActivatableClassActivatableClassId="Lumia.Internal.HMBClient.HMBMessageEventArgs" ThreadingModel="both"/>

          </InProcessServer>

        </Extension>

    and now the live tile is updated in the background.
    I suggest you to update the official examples (if you have not done this already) since they also do not work + these entries in the manifest file are missing.

    best regards,
    Hannes

    Thursday, January 8, 2015 9:46 AM
  • Hi,

    You can try if this work around solution fixes the issue

    A problem in Visual Studio 2013 Update 4: when consuming an SDK you may sometimes get a TypeLoadException; a type from the SDK could not be found during runtime and an exception was thrown.

    This problem can be found described online in several places. If this is an active obstacle for anyone, the workaround is to grab the C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\AppxPackage\ Microsoft.Build.AppxPackage.dll from a machine with VS 2013 Update 3 (where it was working), and replace it on a machine with VS 2013 Update 4.

    This is effectively just copying a file from VS2013Update3 and using it from Update 4.  

    Just note, this fix is needed at App build time. If you are shipping an SDK, the consumers of the SDK need to apply this fix.

    Monday, January 19, 2015 7:47 PM