I have a VS 2010 C# .NET 4 project. The issue is that the program is not breaking on 'NullReferenceException' errors during debugging.
The output window will display the following:
A first chance exception of type 'System.NullReferenceException' occurred in myProgram.exe
...but the debugger will just exit out of the function and continue running the rest of the program.
How do I change this behavior so that the debugger will break on these exceptions?
A NullReferenceException exception is thrown when you try to access a member on a type whose value is null . A NullReferenceException exception typically reflects developer error and is thrown in the following scenarios: You've forgotten to instantiate a reference type.
Handling the error Being a plain old C# exception, NullReferenceException can be caught using a try/catch : try { string s = null; s. ToString(); } catch (NullReferenceException e) { // Do something with e, please. }
The runtime throwing a NullReferenceException always means the same thing: you are trying to use a reference, and the reference is not initialized (or it was once initialized, but is no longer initialized). This means the reference is null , and you cannot access members (such as methods) through a null reference.
Go to Debug -> Exceptions -> Search for NullReferenceException
and check the "thrown" checkbox.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With