I know that when a NullReferenceException gets thrown, the error message states:
Object reference not set to an
instance of an object.
And I realize this message is thrown when I attempt to dereference a null object reference.
The error message implies that there could be a reason for a NullReferenceException besides an object reference being null (perhaps a bad memory address or something similar). Is this the case?
Edit: I’m more concerned with the reasons aNullReferenceException could be thrown than the wording of the error message. The wording of the error message is just what prompted the question.
I suspect it’s trying to be language-neutral. A Visual Basic programmer is used to “nothing” instead of “null”, for example. Obviously the type name isn’t language neutral, but at least if the message is, that’s a start.
I don’t know that you’d get this if somehow you tried to dereference a “bad” memory address… at that point there’s a far worse CLR error involved.
Another possibility is that it’s trying to avoid stating that you’ve explicitly set the value of the reference to null – it could be just the default value of a reference type variable, for example.