Why is the "Link to an object not installed on an instance of the object" not more descriptive?

As a developer, we often encounter this exception: NullReferenceExceptionwith a known error message:

Object reference not set to instance object

Is it impossible for the .NET platform to return something a little more meaningful?

Sort of:

An object of type X named Y is not set to an instance of the object

+5
source share
3 answers

An object has no name - so how can it tell you a name? A null reference could be loaded from a variable - or it could be returned by a method, property, etc.

JIT, , , , , , - , , .

, - , , - , , , .

+15

. , NullReferenceException .:)

, , , . , NullReferenceException, (, ), . , , ArgumentNullException, , -, , : throw new ArgumentNullException("param1").

, , - .

+2

.

+1
source

All Articles