Question A first chance exception?

andimanro

Member
Joined
Jun 7, 2010
Messages
18
Programming Experience
1-3
does anyone know what does this mean ?
"A first chance exception of type 'System.Data.SyntaxErrorException' occurred in System.Data.dll"

thanks in advance...
 
That message means that an exception has been thrown, which is fine. If your app doesn't crash then the exception has been caught, either inside the Framework or in your own code. Search the web for "first chance exception" and you should find the same explanations that I found when I wanted to know what that same message meant.
 
I don't understand why first chance exceptions are reported in the Immediate Window. If the exception was caught, then everything is presumably working as designed, and there is no need to bring it to my attention. Is there any way to prevent the "first chance" messages from appearing in the Immediate Window?

-TC
 
Tools > Options : Debugging > Output Window : Exception Messages (On/Off).

A first chance exception is still a thrown exception, which is indication of a problem that seemingly had to be caught to be resolved. The actual message that appears here is not too informative ('first change of type.. occured in assembly'), but combined with other debug reporting it may be easy to see in which context it happened when debugging 'live'. Perhaps you're getting a lot of first chances that is not expected and decide to take a closer look. The identification of assembly may also be important, perhaps you can solve the problem differently in such a way that another assembly doesn't throw (for example input parameters validation), or perhaps solve logical problems in your own code. It could be that what you initially solved by simply adding a Try block now you can rearrange, it is part of the debugging process to identify and solve problems that you first didn't anticipate. As such avoid Try blocks whenever possible, unless you know they can't or shouldn't be avoided, because when the problem occurs you're forced to resolve it right there and not lazily let the first chance pass.
 
I don't understand why first chance exceptions are reported in the Immediate Window. If the exception was caught, then everything is presumably working as designed, and there is no need to bring it to my attention. Is there any way to prevent the "first chance" messages from appearing in the Immediate Window?

-TC
The fact that an exception is being caught doesn't mean that it should have been allowed to be thrown in the first place. If you don't want to use the information then don't but why hide it when even it's certainly not hurting you and even if it only helps 1 time out of 1000 it has still helped?
 
Back
Top