skeleton and nullreferenceexception RRS feed

  • Question

  • skeleton is not being created in the following segment. I just updated to Beta 2. Normally, I don't believe SetColor is called until a skeleton is being tracked (SetColor creates an object of skeleton.Joints[...], this initialization throws the null reference exception). Now SetColor is called too early.


    void nui_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
                SkeletonFrame allSkeletons = e.SkeletonFrame;
                //get the first tracked skeleton
    	    // skeleton SkeletonData reference is global	
                skeleton = (from s in allSkeletons.Skeletons
                                         where s.TrackingState == SkeletonTrackingState.Tracked
                                         select s).FirstOrDefault();
                // set background color
                SetColor(proportion, skeleton);


    there are six skeletons in allSkeletons.Skeletons and none are being tracked. shouldn't this loop through skeletons until it sees that one is being tracked? just to reiterate, I just switched to Beta 2.

    Thanks for the help.

    Sunday, November 6, 2011 9:36 AM


  • I love when there are easy solutions:

    if (skeleton != null)
                    SetColor(proportion, skeleton);


    Sunday, November 6, 2011 6:10 PM