locked
SensorCore SDK Steps example app not working RRS feed

  • Question

  • Hi,

    I am creating an app that uses the sensor core SDK and when trying to start it on my lumia 630 (which has a motion sensor), i got the error: System.TypeLoadException: Requested Windows Runtime type 'Lumia.Sense.StepCounter' is not registered. ---> System.Runtime.InteropServices.COMException: Class not registered

    So i tried the steps example from

    http://developer.nokia.com/resources/library/Lumia/sensorcore-sdk/samples.html

    Unvortunate I got the same error.
    Directly after the app has been started, it crashes with an unhandled exception

    {System.TypeLoadException: Requested Windows Runtime type 'Lumia.Sense.StepCounter' is not registered. ---> System.Runtime.InteropServices.COMException: Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
       --- End of inner exception stack trace ---
       at System.StubHelpers.StubHelpers.GetWinRTFactoryObject(IntPtr pCPCMD)
       at Lumia.Sense.StepCounter.IsSupportedAsync()
       at Steps.StepsEngine.<InitializeSensorAsync>d__33.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
       at Steps.StepsEngine.<InitializeAsync>d__2b.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
       at Steps.App.<Application_Launching>d__0.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__3(Object state)} 

    Build Configuration is DEBUG and ARM.

    Does anybody have the sampe prboelms or were you able to run the example?
    As said: The problem occurs in the example app, not in my own app.

    best regards,
    Hannes


    • Edited by HannesBiri Friday, November 21, 2014 1:54 PM
    Friday, November 21, 2014 1:50 PM

All replies

  • Btw. when I set the build target to x86 and run the app in the emulator, I am getting nearly the same exception:

    System.TypeLoadException was unhandled by user code
      HResult=-2146233054
      Message=Requested Windows Runtime type 'Lumia.Sense.Testing.SenseRecording' is not registered.
      Source=mscorlib
      TypeName=Lumia.Sense.Testing.SenseRecording
      StackTrace:
           at System.StubHelpers.StubHelpers.GetWinRTFactoryObject(IntPtr pCPCMD)
           at Lumia.Sense.Testing.SenseRecording.LoadFromFileAsync(String filename)
           at Steps.StepsEngine.<InitializeSimulatorAsync>d__3d.MoveNext()
        --- End of stack trace from previous location where exception was thrown ---
           at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
           at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
           at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
           at Steps.StepsEngine.<InitializeAsync>d__2b.MoveNext()
        --- End of stack trace from previous location where exception was thrown ---
           at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
           at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
           at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
           at Steps.App.<Application_Launching>d__0.MoveNext()
      InnerException: System.Runtime.InteropServices.COMException
           HResult=-2147221164
           Message=Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
           ErrorCode=-2147221164
           InnerException: 

    Friday, November 21, 2014 2:03 PM
  • UPDATE

    I tested this with an old Version (1.0) of the steps example, which uses an the older (1.0) version of the SensorCore SDK and everything works fine!

    In Version 1.1 the app throws the exception at the call to await StepCounter.IsSupportedAsync()

    In InitializeSensorAsync.

    So in my opinion this is a problem of SDK Version 1.1.

    Saturday, November 22, 2014 8:37 PM
  • What type of windows phone 8.1 app are you creating?  I dont think the sensor works with the silverlight app type
    Sunday, November 23, 2014 2:58 PM
  • Thanks for your reply!

    The example app version 1.1 is a windows phone 8.1 Silverlight App, so I expect this to work with Silverligt apps too. :)

    The old version (1.0) is a SL 8.1 app too and it is working.

    As written: the example app, provided by nokia (now MS) is not working so anybody should be able to reproduce the problem: Download the steps v1.1 example app from: https://github.com/nokia-developer/steps/archive/v1.1.zip 

    Deply it to the device and start the app.

    Sunday, November 23, 2014 3:46 PM
  • Sunday, November 23, 2014 3:57 PM
  • I will test it.

    On the example page http://developer.nokia.com/resources/library/Lumia/sensorcore-sdk/samples.html

    some examples are in silverlight, other are universal apps, so this really should not matter.

    best regards,
    Hannes

    Monday, November 24, 2014 7:40 AM
  • Wow, now this is really strange.

    I deployed the "quick start" examle, which is an universal app to the phone: works

    Then i rebuilt my app, which is a universal app and was NOT working, deployed it to the phone: works now!

    (This is something I really do not understand since I already did this many times)

    Finally I rebuilt the updated steps example from: http://developer.nokia.com/resources/library/Lumia/sensorcore-sdk/samples.html#toc_Steps

    This is still not working, so in face there is a sample online in the documentation, which is not working, maybe MS should check and fix this.

    Difference: It is a SL 8.1 version.

    So it seems that this is really only working in the universal app model, which uses the WinRT version of the runtime and it is not working in SL 8.1.

    Why it was not working in my own app is still not explainable to me but I am glad that it works now. :)

    Monday, November 24, 2014 6:57 PM
  • Hi Hannes,

    Glad to know your project works now. And thanks for reporting the issue. We will test it and see what happened.

    Could you please let me know whether you just updated your VS to VS 2013 update 4? We did get some similar issues like "Class not registered" issue after updating to update 4. And the issue should only occur during runtime, but no error during build.  Is that same behavior as the issue you encountered?



    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    Alan Yao
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.



    Tuesday, November 25, 2014 11:57 AM
  • Hi Alan,

    thank you for your reply!

    Yes, in fact I really installed Visual Stuidio 2013 Update 4 a few days ago.
    The problem also occurs only at runtime, at compile time there are no errors.

    best regards,
    Hannes

    Tuesday, November 25, 2014 12:16 PM
  • Hi,

    we have a similar issue not only with the Sensor SDK, but also with the Imaging SDK.
    We added a background task as a "Windows Runtime Component" to the solution.

    We are receiving this error if are setting the output type to "Windows Runtime Component",

    a "Class Library" as output type fixed the TypeLoadException, but caused other issues.

    As far as I know, the background task has to stay a "Windows Runtime Component",

    so we are still looking for a solution.

    We also have the Visual Studio 2013 Update 4 installed.

    Wednesday, November 26, 2014 4:22 PM
  • ...and it stopped working in my app again. :(

    > Requested Windows Runtime type 'Lumia.Sense.StepCounter' is not registered.

    What did I change?
    In fact nothing, which means: I added a method to calculate distance based on steps value, moved some common methods to a universal app portable class library...
    When trying to deploy it to the phone, i got the exception mentioned above.

    So I even git-reverted all my changes, uinstalled the app from the phone, restarted visual studio.

    Result: The error still exists, when trying to deploy to the device.
    It occurs, when the 'StepCounter' class is accessed for the first time, which in my app is the call to "await StepCounter.IsSupportedAsync()"

    It was working yesterday, it is not working today without any changes, so this error is "random", which usually means it's some runtime-condition problem.

    Meaning: The app accesses the StepCounter, when it is not "registered" internally.
    Please MS, fix this soon - at the moment the lumia sensor core SDK is not useable. :(

    The problem should be simple to reproduce since it occurs in the official "steps sample", which I liked above.

    best regards,
    Hannes Biribauer

    Friday, November 28, 2014 9:15 AM
  • Btw., when testing this in the emulator, where the "Sensor Core Testing" nuget package is used, I get an "Additional information: Requested Windows Runtime type 'Lumia.Sense.Testing.SenseRecording' is not registered." exception.

    The exception occurs on the call to:

    var obj = await SenseRecording.LoadFromFileAsync("Simulations\\short recording.txt");

    Update:

    It gets even more weird...

    Meanwhile I wrote my own implementation for 'IStepCounter' so I can use it in the emualtor.
    (since the call to "StepCounterSimulator.GetDefaultAsync(...)" fails)

    But the call to "ActivityMonitorSimulator.GetDefaultAsync()" works!

    So using the test implementation of the acitivity montor works, while using the test implementation of the steps counter fails.

    Update 2:

    3 hours later, not also the call to "await ActivityMonitorSimulator.GetDefaultAsync()" fails.

    Exception: Additional information: Requested Windows Runtime type 'Lumia.Sense.Testing.ActivityMonitorSimulator' is not registered.

    ...will need to write my own implementation for this too. :(

    • Edited by HannesBiri Friday, November 28, 2014 1:51 PM added update 2
    Friday, November 28, 2014 9:34 AM
  • Hi Hannes,

    it seems that this is indeed a VS Update 4 issue. 
    Our code worked with an older version of Visual Studio (VS 2013 Update 2).

    Friday, November 28, 2014 10:01 AM
  • Hi Chris,

    thanks for the info!

    ...don't know if this should calm me down or make me even more nervous: An update of the development environment breaks existing code of a WinRT component. ;)

    How do these things relate?
    Will be interresting to get an explanation for this from MS.

    Too bad, I installed the update on my only dev. computer so I can only wait for a fix at the moment.

    greetings,
    Hannes

    PS: looking forward to the SensorCore integration in runtastic!! :)


    • Edited by HannesBiri Friday, November 28, 2014 11:47 AM
    Friday, November 28, 2014 11:46 AM
  • Hi Hannes,

    Thanks again for reporting this. I was able to reproduce this issue, and what I found is some required entries were not added into AppxManifest file.
    Take this case for example:
    Here is the one built with Visual Studio 2013 Update 3:

      <Extensions>
        <Extension Category="windows.activatableClass.inProcessServer">
          <InProcessServer>
            <Path>CLRHost.dll</Path>
            <ActivatableClass ActivatableClassId="BackgroundTasks.StepTriggerTask" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="BackgroundTasks.Helper" ThreadingModel="both" />
          </InProcessServer>
        </Extension>
        <Extension Category="windows.activatableClass.inProcessServer">
          <InProcessServer>
            <Path>Lumia.Sense.Testing.dll</Path>
            <ActivatableClass ActivatableClassId="Lumia.Sense.Testing.AltitudeMeterSimulator" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="Lumia.Sense.Testing.SenseRecorder" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="Lumia.Sense.Testing.SenseRecording" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="Lumia.Sense.Testing.TrackPointMonitorSimulator" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="Lumia.Sense.Testing.StepCounterSimulator" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="Lumia.Sense.Testing.PlaceMonitorSimulator" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="Lumia.Sense.Testing.ActivityMonitorSimulator" ThreadingModel="both" />
          </InProcessServer>
        </Extension>
        <Extension Category="windows.activatableClass.inProcessServer">
          <InProcessServer>
            <Path>Lumia.Sense.dll</Path>
            <ActivatableClass ActivatableClassId="Lumia.Sense.ActivityMonitor" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="Lumia.Sense.TrackPoint" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="Lumia.Sense.StepCount" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="Lumia.Sense.SenseHelper" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="Lumia.Sense.StepCounterReading" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="Lumia.Sense.SenseTrigger" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="Lumia.Sense.StepCounter" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="Lumia.Sense.ActivityMonitorReading" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="Lumia.Sense.TrackPointMonitor" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="Lumia.Sense.AltitudeMeterReading" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="Lumia.Sense.Place" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="Lumia.Sense.AltitudeMeter" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="Lumia.Sense.PlaceMonitor" ThreadingModel="both" />
          </InProcessServer>
        </Extension>
      </Extensions>

    And here is the one built in Visual Studio 2013 Update 4:

      <Extensions>
        <Extension Category="windows.activatableClass.inProcessServer">
          <InProcessServer>
            <Path>CLRHost.dll</Path>
            <ActivatableClass ActivatableClassId="BackgroundTasks.Helper" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="BackgroundTasks.StepTriggerTask" 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.StepCount" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="Lumia.Sense.StepCounterReading" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="Lumia.Sense.AltitudeMeterReading" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="Lumia.Sense.ActivityMonitorReading" ThreadingModel="both" />
            <ActivatableClass ActivatableClassId="Lumia.Sense.TrackPoint" ThreadingModel="both" />
          </InProcessServer>
        </Extension>
      </Extensions>

    The above missing cause the problem.

    [Update]:

    To work around this issue, do the following:

    1. Find out what's the class that run into "Class not registered" from exception detail.

    2. Build the solution and check if appxmanifest file has your class listed in output folder.

    3. If 2 is yes, this may be a different issue. If not, open your solution in VS and add the missing extension in Package.appxmanifest file. Check InProcessServer to see what's the hierarchy.

    If the above workaround doesn't work for you, post a question to bring our attention. 


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    Alan Yao
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.




    Monday, December 1, 2014 9:59 AM
  • Thank you, Alan.

    This solution also worked for the imaging SDK.

    Monday, December 1, 2014 7:30 PM
  • Thanks for the reply but at the moment this does not solve my problem.

    My app is an "universal app", so it has a 'Package.appxmanifest' for the windows phone part of the universal app.

    When I try to add '<Extension Category="windows.activatableClass.inProcessServer">' Visual Studio shows an error that this category is not contained in the declared namespace.

    See:

    Monday, December 1, 2014 9:25 PM
  • Update:

    ok, the 'Extensions' element that already exists under the Applications Element must be added separatly AFTER the Applications Element.

    </Applications>
      <Extensions>
        <Extension Category="windows.activatableClass.inProcessServer">

    ...

    This way it works, no schema validation errors.

    The app now works on the device too - cool + I hope, it stays this way :)

    Thanks for your help + best regards,
    Hannes

    • Edited by HannesBiri Monday, December 1, 2014 9:50 PM fixes im my code
    Monday, December 1, 2014 9:25 PM
  • Hi Hannes and Chrisika,

    Thanks for your confirmation.

    In case anyone else does not know how to make it work, I updated my previous post.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    Alan Yao
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, December 2, 2014 1:59 AM
  • Please don't forget to update the example from the lumia examples page. :)

    At the moment my app and the example app too both say: SensorSDK not supported on my Lumia 630 Test Phone and a Lumia 1520 with Cyan update.

    The call to 'StepCounter.IsSupportedAsync()' returns false at the moment.

    Exception message:

    A first chance exception of type 'System.UnauthorizedAccessException' occurred in ....WindowsPhone.exe

    Additional information: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

    Sensors and Location Service are both enabled on the phone.

    It was working yesterday, it is not working now. :(
    And yes, I did not change anything, just re-deployed it.

    Not very stable this whole thing...in my personal opinion.

    UPDATE: Removed Capability to "Sensors" (which has noting to do with SensorCoreSDK), did a rebuild, deployed to the phone and: Is IS working again now?!

    There seems to be some serious issues in this SDK...I know that's not your fault but maybe MS should add some testing code and test it across some devices.

    UPDATE 2: stopped working again. :(

    Important: All these problems can be reproduced with the "Steps example app", so these problems are not related to my app. The example app sometimes works, other times it does not work + says that the phone does not support SensorCore SDK.

    As far as I remember, these problems did not occur with the previous version (LumiaSensorCoreSDK.0.9.1.3) of SensorCore SDK.




    • Edited by HannesBiri Tuesday, December 2, 2014 9:16 PM
    Tuesday, December 2, 2014 7:49 PM
  • Hi Hannes,

    Thanks for updating.

    But seems the new issue you mentioned is not related to the original one. To avoid any confusion, could you please start a new thread for the new question?

    Thanks for your understanding.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    Alan Yao
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, December 3, 2014 1:49 AM
  • Hi Alan,

    I did so and started a new thread: https://social.msdn.microsoft.com/Forums/windowsapps/en-US/6ea4cbbc-8649-462e-9ea2-8cfbeac672e7/lumia-sensorcoresdk-103263-not-working?forum=wpdevelop

    I did many tests and tried to explain things as detailed as possible.

    best regards,
    Hannes

    Wednesday, December 3, 2014 7:22 PM
  • Just so everyone knows, I'm using Google Analytics (http://googleanalyticssdk.codeplex.com/) and was having the same issue described here.

    Alan Yao' solution worked for me too

    Edit: this is the config I had to add

    	<Extensions>
    		<Extension Category="windows.activatableClass.inProcessServer">
    			<InProcessServer>
    				<Path>CLRHost.dll</Path>
    				<ActivatableClass ActivatableClassId="GoogleAnalytics.EasyTracker" ThreadingModel="both"/>
    			</InProcessServer>
    		</Extension>
    	</Extensions>


    http://about.me/sebagomez


    Monday, December 22, 2014 5:50 PM
  • The solution is here:

    http://answers.flyppdevportal.com/categories/winphone/wpdevelop.aspx?ID=6ea4cbbc-8649-462e-9ea2-8cfbeac672e7

    Tuesday, January 6, 2015 10:15 AM
  • Thanks for your reply!
    Wednesday, January 7, 2015 7:14 PM
  • Right, specifically, the nuget package is wrong, it installs the following into your project:

    <HintPath>..\packages\LumiaSensorCoreSDK.1.1.1.1\lib\portable-wpa81+wp81\x86\Lumia.Sense.winmd</HintPath>

    It should be use "$(Platform)" instead of hard coding "x86".

    <HintPath>..\packages\LumiaSensorCoreSDK.1.1.1.1\lib\portable-wpa81+wp81\$(Platform)\Lumia.Sense.winmd</HintPath>

    Tuesday, March 3, 2015 7:18 PM