chris.au
chris.au

Reputation: 1108

Catch Exception in Application Startup (VS.Net)

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

Upvotes: 1

Views: 283

Answers (3)

Ashish Gupta
Ashish Gupta

Reputation: 15139

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".

Upvotes: 0

Brian Rasmussen
Brian Rasmussen

Reputation: 116471

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.

Upvotes: 1

Chris
Chris

Reputation: 27394

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

Upvotes: 0

Related Questions