编译错误 [英] complie Errors

查看:79
本文介绍了编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好


Visual studio 2005

Visual Basic

windows移动应用程序


我从imediate窗口得到这个类型的第一次机会异常

'System.InvalidCastException''发生在System.Drawing.dll中


现在程序仍在运行,但每次我交换时都会出现此错误

文件中的图像


我使用的代码如下


Dim leftImage As Bitmap

leftImage =新位图(boardImagesPath +

CStr(boardPositionP1 - 1)+" .jpg")

leftPb.Image = leftImage

我不知道这是否足够信息任何帮助都会很棒


提前致谢


Roger

解决方案

新位图&你把它设置为JPG

" Roger Vale" < ro ******** @ btinternet.comwrote in message

news:uy ************** @ TK2MSFTNGP03.phx.gbl .. 。


大家好


Visual studio 2005

Visual Basic

windows移动应用程序


我从imediate窗口得到这个
的第一次机会异常



type


'System.InvalidCastException''发生在System.Drawing.dll中


现在程序仍在运行,但似乎出现此错误每次i



交换


来自文件的图像


我正在使用的代码如下


Dim leftImage As Bitmap


leftImage =新位图(boardImagesPath +

CStr(boardPositionP1 - 1)+" .jpg")

leftPb.Image = leftImage


我不知道这是不是足够的信息任何帮助都会很棒


提前致谢


Roger



当您在IDE中调试项目时,您可能会看到此消息,但是您在编译项目时将无法看到



当调试应用程序时,调试器会在

遇到异常时收到通知此时,应用程序被暂停并且

调试器决定如何处理异常。第一次通过

这种机制被称为第一次机会。例外。根据

调试器的配置,它将恢复应用程序并传递

异常,否则将使应用程序暂停并进入调试

模式。如果应用程序处理异常,它会继续正常运行




如果应用程序没有处理异常,则调试器为

重新通知。这被称为第二次机会。例外。调试器

再次暂停应用程序并确定如何处理此异常。

通常,调试器配置为停止第二次机会(未处理)

输入异常和调试模式,允许你调试。


第一次机会异常消息最常见的并不代表

代码中存在问题。对于优雅处理异常的应用程序/组件,

第一次机会异常消息让开发人员知道遇到并处理了特殊的

情况。

对于没有异常处理的代码,调试器将收到第二个
机会异常通知,并将以未处理的异常停止。


因为你没有得到未处理的异常,(或者如果你是你

还没有这么说),那么你必须有一些异常处理代码,你可以从你的b
$帖子。如果是这种情况那么你就没什么可担心的了。


顺便说一句,你是否知道你可以简单地将这段代码:


leftPb.Load(boardImagesPath + CStr(boardPositionP1 - 1)+" .jpg")


或更好:


leftPb.Load(boardImagesPath& CStr(boardPositionP1-1)&" .jpg")

" Roger Vale" < ro ******** @ btinternet.comwrote in message

news:uy ************** @ TK2MSFTNGP03.phx.gbl .. 。


大家好


Visual studio 2005

Visual Basic

windows mobile应用程序


我从imediate窗口得到这个

类型的第一次机会例外

''系统System.Drawing.dll中发生.InvalidCastException''


现在程序仍在运行,但每次出现此错误时都会出现

swap

来自文件的图像


我正在使用的代码如下


Dim leftImage As Bitmap


leftImage =新位图(boardImagesPath +

CStr(boardPositionP1 - 1)+" .jpg")

leftPb.Image = leftImage

我不知道这是否足够信息任何帮助都会很好


提前致谢


Roger


感谢您的回复


我没有得到未处理的回复,我读过这不会导致<不在调试模式下运行时
a问题。

但它在调试模式下运行时确实会减慢应用程序

有什么方法可以防止这个?


并感谢编码建议,我确实按照你建议的方式使用了代码

但是已经改变它以试图消除这个第一次机会错误


" Stephany Young" < noone @ localhostwrote in message

news:Om ************** @ TK2MSFTNGP03.phx.gbl ...


当您在IDE中调试项目时,您可能会看到此消息,但是在编译项目时,您将永远不会看到它。$ / b $ b。


当调试应用程序时,无论何时遇到异常,调试器都会收到通知

遇到异常此时,应用程序被暂停

和调试器决定如何处理异常。通过这种机制的第一遍

被称为第一次机会。例外。根据

调试器的配置,它将恢复应用程序和

传递异常,否则将使应用程序暂停并输入

调试模式。如果应用程序处理异常,它会继续正常运行




如果应用程序没有处理异常,则调试器为

重新通知。这被称为第二次机会。例外。调试器

再次暂停应用程序并确定如何处理此

异常。通常,调试器配置为在第二次机会停止

(未处理)异常并进入调试模式,允许您进行调试。


第一次机会异常消息最多通常并不意味着代码中存在问题

。对于处理例外情况的应用程序/组件优雅,第一次机会异常消息让开发人员知道遇到并处理了

异常情况。

对于没有异常处理的代码,调试器将收到第二个
机会异常通知,并将以未处理的异常停止。


因为你没有得到未处理的异常,(或者如果你是你

还没有这么说),那么你必须有一些异常处理代码,你可以从你的b
$帖子。如果是这种情况那么你就没有什么可担心的了。


顺便说一句,你是否知道你可以简单地将这段代码:


leftPb.Load(boardImagesPath + CStr(boardPositionP1 - 1)+" .jpg")


或更好:


leftPb.Load(boardImagesPath& CStr(boardPositionP1-1)&" .jpg")


" Roger Vale" < ro ******** @ btinternet.comwrote in message

news:uy ************** @ TK2MSFTNGP03.phx.gbl .. 。


>大家好

Visual Studio 2005
Visual Basic
windows移动应用程序
<我从中级窗口得到这个在System.Drawing.dll中发生的第一次机会异常
''System.InvalidCastException''
现在程序仍然运行,但这个错误似乎每次都出现
交换一个文件中的图像

我正在使用的代码如下

Dim leftImage作为位图

leftImage =新位图(boardImagesPath +
CStr(boardPositionP1 - 1)+" .jpg")
leftPb.Image = leftImage

我不知道这是否足够信息任何帮助都会很棒

提前致谢

Roger



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

解决方案

New Bitmap & you set it to 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



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



Thanks for the reply

I am not getting a unhandled reply and i have read that this will not cause
a problem when not running in debug mode.
But it does slow down the application while it runs in debug mode
is there any way to prevent this?

and thanks for the coding advice I did have the code the way you suggested
but have changed it arround to try and remove this first chance error

"Stephany Young" <noone@localhostwrote in message
news:Om**************@TK2MSFTNGP03.phx.gbl...

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



这篇关于编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆