| Start |
|---|
| NullReferenceException explained A To debug such an exception, it's quite easy: on the line where the exception is thrown, you just have to look before every ' Where does my exception come from? Either:
In debug mode, you only have to put your mouse cursor on every of these elements and you will find your null reference. Then, what you have to do is understand why it doesn't have a value. The correction totally depends on the goal of your method. Have you forgotten to instantiate/initialize it? Are you supposed to do something different if the object is null? Or maybe someone gave you a null argument, and was not supposed to: In any case, remember that a method should never throw a NullReferenceException. If it does, that means you have forgotten to check something. |
Read Article
https://develop.horje.com/learn/1434/reference