开发者

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 debugge开发者_运维技巧r 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


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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜