none
Object reference not set error with refreshed SDK? RRS feed

  • Question

  • Hi,

    I used this piece of code to track only one user at any point of time, worked fine with earlier SDK, but throws object reference not set to instance of an object exception with the refreshed SDK.

    SkeletonData data = (from s in allSkeleton.Skeletons
                                     where s.TrackingState == SkeletonTrackingState.Tracked
                                     select s).FirstOrDefault();

     

    Can anyone explain what is the issue here?

     

    Thanks,

    Bharat.

    Friday, August 5, 2011 8:29 AM

Answers

  • Correct, it is now possible for that query to end up with 'data' variable equal to null, since the SkeletonFrameReady event will fire even if there are no skeletons tracked. You should therefore check that 'data' != null before using it further.

    Eddy


    I'm here to help
    • Marked as answer by ykbharat Monday, August 22, 2011 9:43 AM
    Saturday, August 6, 2011 2:15 AM

All replies

  • hi, i think that we have the same question: look http://social.msdn.microsoft.com/Forums/en-US/kinectsdknuiapi/thread/143b0b27-8f54-4687-ace5-c5ea576e2224

    or this Eddy Escardo-Raffo says:

    That video was authored when Beta 1 was released, and the behavior it describes was accurate at that point. However, we recently shipped Beta 1 refresh and behavior was changed in managed API to always fire event whenever there is a depth frame, even if there is no skeleton detected. This was done to match native code behavior.

    I'm sorry for the confusion. I will let the right people know about this.

    Eddy

    • Proposed as answer by MakitoMakito Friday, August 5, 2011 4:40 PM
    Friday, August 5, 2011 4:40 PM
  • Correct, it is now possible for that query to end up with 'data' variable equal to null, since the SkeletonFrameReady event will fire even if there are no skeletons tracked. You should therefore check that 'data' != null before using it further.

    Eddy


    I'm here to help
    • Marked as answer by ykbharat Monday, August 22, 2011 9:43 AM
    Saturday, August 6, 2011 2:15 AM