0 votes
by (8.2k points)
edited by

I have some code and when it executes, it throws a NullReferenceException, saying: Object reference not set to an instance of an object.

What does this mean, and what can I do to fix this error?

NullReferenceException: Object reference not set to an instance of an object Vuforia.VuforiaRuntime Utilities.IsVuforiaEnabled()

Null Reference Exception: says "Object reference not set to an instance of an object" it's very annoying  

1 Answer

0 votes
by (8.2k points)
edited by
 
Best answer

It is certainly caused by an error of some script that shows some essential things are camera, not detects so it throws null reference exception.

  • This error is caused when your script can't access an object whose reference you are trying to get. The quick workaround to this problem is to change the access modifier of the type to the public so rather than initializing it in Awake() or Start() drag the component in the inspector window. 

  • NullReferenceException happens when your script code tries to use a variable which isn’t set (referencing) and object. The error message that appears tells you a great deal about where in the code the problem happens. NullReferenceException can be avoided by writing code that checks for null before accessing an object, or uses try/catch blocks.

TechXR runs courses in AR / VR / Metaverse / Game Development. Some of the popular Q&A in our courses are available here for easy discovery.

113 questions

117 answers

8 comments

99.7k users

...