Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.
Options

NullReferenceException fix

I am getting the error message below. Can someone please tell me how to fix.

NullReferenceException: Object reference not set to an instance of an object
GazeManager.Update () (at Assets/Assets/GazeAssets/HoloToolkit/Input/Scripts/GazeManager.cs:57)



Comments

  • Options

    I am getting the error message below. Can someone please tell me how to fix.

    NullReferenceException: Object reference not set to an instance of an object
    GazeManager.Update () (at Assets/Assets/GazeAssets/HoloToolkit/Input/Scripts/GazeManager.cs:57)


  • Options

    Looks like gazeStablizer hasn't been initialized. The only other possibilities for null references are gazeOrigin or the Camera.main gazeOrigin looks right. And there is a camera in your scene so I don't think they are the issue.

    Make sure you initiate gazeStablizer in Start() or Awake().

  • Options

    @mavasher I tried to initiate gazeStablizer in Awake() and Start() and I still received the same error.

    gg22.JPG 197.8K
  • Options
    HoloSheepHoloSheep mod
    edited May 2016

    First determine which object is null by either stepping through the code and inspecting the objects at runtime, or by adding Debug.Log() statements inline and watching the output at runtime.

    The error statement is indicating that the error is in line 57. So the primary potential suspects are gazeStabilizer and gazeOrigin.

    Once you determine which object is null, then you need to figure out why.
    Check where the object is declared and initialized.
    Check if you have the necessary using statements.

    BTW... if you post your questions on the forum as "Ask a Question" instead of "New Discussion" they are more likely to be seen in the system as unanswered and receive quicker responses.

    Windows Holographic User Group Redmond

    WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
    WinHUGR YouTube Channel -- live streamed meetings

  • Options

    @evanjames please check if you have GazeStabilizer.cs attached to your Managers object. Or which ever gameobject GazeManager.cs is attached to. Or else you can remove the code that uses GazeStabilizer.cs to see if that was it.

  • Options

    @HoloSheep @neerajwadhwa Thank you for the tip. I am new to being fully active on forums. I hope I do not get flagged for spam

  • Options

    @neerajwadhwa Adding component GazeStabilizer.cs to the Managers object worked perfectly. :)

  • Options
    creigleecreiglee
    edited August 2016

    You are trying to use something that is null . This means you either set it to null, or you never set it to anything at all.

    Like anything else, null gets passed around. If it is null in method "A", it could be that method "B" passed a null to method "A".

    The rest of this article goes into more detail and shows mistakes that many programmers often make which can lead to a NullReferenceException.

    SqlConnection connection = null;
    connection.Open();

    When you run this code, you will get :

    System.NullReferenceException: Object reference not set to an instance of an object.

    The message "Object not set to instance of Object" means you are trying to use an object which has not been initialized.

    You can avoid this error by coding like this:

    if (connection != null)
    {
    connection.Open();
    }

    Lee

  • Options

    I encountered this and it was due to my camera not being tagged MainCamera. A new scene comes with the Main Camera assigned the Tag MainCamera by default so I must have inadvertently changed the Tag setting.

Sign In or Register to comment.