C # doesn't throw NullReferenceException on developer machine
I have some code that looks like this:
public partical class frmXXX : Form
{
SomeObject foo = null;
public void XYZ()
{
foo.ABC.DEF(foo.XXX, foo.YYY, foo.ZZZ);
somethingElse();
}
...
}
Looks like I had an error where I was calling XYZ()
when foo
it is null. The program crashed with a NullReferenceException on the client, which is what I would expect. However, on my development machine, I am not getting the exception. I also checked with the debugger that foo is actually null. The debugger says it is zero.
After calling the null object, the method will complete, so somethingElse();
it is not called. It looks like a silent exception. Is there a chance that my development machine is misconfigured or can I enable something?
source to share
Cntrl + Alt + E (or Debug -> Exceptions or in VS2017 Debug -> Windows -> Exception Settings ) Select Reset All , this will return default exceptions.
Also make sure Only My Code is checked . You can find this under Debug -> Options . This will take you to the Debugger -> General options . You can check My Code Only here .
source to share