You may see this message at when you 'debug' the project in the IDE, but you
will never see it when you compile a project.
When an application is being debugged, the debugger gets notified whenever
an exception is encountered At this point, the application is suspended and
the debugger decides how to handle the exception. The first pass through
this mechanism is called a "first chance" exception. Depending on the
debugger's configuration, it will either resume the application and pass the
exception on or it will leave the application suspended and enter debug
mode. If the application handles the exception, it continues to run
normally.
If the application does not handle the exception, the debugger is
re-notified. This is known as a "second chance" exception. The debugger
again suspends the application and determines how to handle this exception.
Typically, debuggers are configured to stop on second chance (unhandled)
exceptions and debug mode is entered, allowing you to debug.
First chance exception messages most often do not mean there is a problem in
the code. For applications / components which handle exceptions gracefully,
first chance exception messages let the developer know that an exceptional
situation was encountered and was handled.
For code without exception handling, the debugger will receive a second
chance exception notification and will stop with a unhandled exception.
Because you are not getting an unhandled exception, (or if you are you
haven't said so), then you must have some exception handling code that you
ommitted from your post. If that is the case then you have nothing to worry
about.
By the way, are you aware that you can simply that piece of code to:
leftPb.Load(boardImagesPath + CStr(boardPositionP1 - 1) + ".jpg")
or, even better:
leftPb.Load(boardImagesPath & CStr(boardPositionP1 - 1) & ".jpg")
"Roger Vale" <ro********@btinternet.comwrote in message
news:uy**************@TK2MSFTNGP03.phx.gbl...
Hi all
Visual studio 2005
Visual Basic
windows mobile application
I am getting this from the imediate window A first chance exception of
type
'System.InvalidCastException' occurred in System.Drawing.dll
Now the program still runs but this error seems to appear every time i
swap
an image from a file
Code i am using is as follows
Dim leftImage As Bitmap
leftImage = New Bitmap(boardImagesPath +
CStr(boardPositionP1 - 1) + ".jpg")
leftPb.Image = leftImage
I dont know if this is enough information any help would be great
Thanks in advance
Roger