views:

49

answers:

3

I'm getting a System.NullReferenceException when my application starts up (after a small login screen) which doesn't crash the entire app but prevents it from loading correctly.

How can I get the VS.Net debugger to stop at the error so I can fix it?

The output I'm getting in the Immediate Window is:

A first chance exception of type 'System.NullReferenceException' occurred in GrelisCrampApp.exe

A: 

At what point does this occur?

It is likely an issue in your destructor for the login form, or something that happens after this.

I suggest adding try catch blocks around code in that area of the program and seeing if you can catch where it is going wrong. This should help you narrow down the issue easily

Chris
+1  A: 

Go to Debug > Exceptions and turn on Thrown for Common Language Runtime Exception. That will cause VS to break when the exception is thrown instead of when it is unhandled.

Brian Rasmussen
A: 

Try the following once:-

  1. Navigate to "Debug/Exceptions"

  2. Expand the "Common Language Runtime Exceptions" tree.

  3. Expand the "System" branch.

  4. Scroll down to where "NullReferenceException" is, and check the "throw" checkbox, and uncheck the "user-handled".

ydobonmai