Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Little problem... when reaching a runtime error, the program doesn't seem to break giving me a warning that something is wrong and leaving me the choice to break the program or to continue it, but just leaves the sub/function where the exception is thrown.

 

eg. Suppose the following line is reached and the value of me.txtTextbox.text = "a"

 

myInt = convert.ToInt32(me.txtTextbox.text)

 

The running program doesn't inform me about this problem!!! The routine containing that line is just left....

 

If I put however

 

try
   myInt = convert.ToInt32(me.txtTextbox.text)
catch e as exception
   msgbox("something wrong.")
end try

 

the messagebox is displayed.

 

I know for sure that some time ago, without having the try-block, I would have had a message box coming up asking me to continue or to break the program. When I selected break, I would be shown the line with the problem. Is there a general setting in the IDE that influences this? I use Visual Studio .NET...

qrt
Posted
The program will not break if the error is handled by a Try...Catch, it should come up with error if there is not Try...Catch around it
.Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?
Posted
That's the problem.... it does not break without a Try Catch, no message box is even shown at all. So it took me a while before I even noticed that some part of the code (starting from myInt = convert.ToInt32(me.txtTextbox.text) for example) never executed. The routine is just left....
qrt
Posted
And in some of the projects I work on, behaviour is as expected. A message box pops up asking to break or continue.... It's just that in some other projects this is not the case. And this is not about nested error handling blocks....
qrt
Posted

Kurt,

 

Do you have any other Try Catch blocks in your application? You may have one higher up in the code which is wrapped around the function that executes myInt = convert.ToInt32(me.txtTextbox.text).

Posted
no, no nested error handlers... Besides, when I execute the program step by step with the debugger, no jump to any Catch block is made. The routine is left when the line is reached, and that's it. The program keeps running.
qrt
Posted

Are you sure you aren't calling any methods that have try catch in them without warnings?

Try setting the program to debug if it isn't already.

What OS is this on?

Can you show us the actual code?

Are you saying that the code below your problem area in the method is just skipped when there is a problem?

C#
Posted

help....

 

Yes, the code is skipped. This is both the case on my Windows 2000 and Windows XP systems. I just changed in the exceptions dialogue box (file menu Debug --> Exceptions) that my debugger should break when the exception is thrown, rather than when the exception is unhandled. In that case the break comes 2 times.....

 

1./ A first chance exception of type 'System.FormatException' occurred in mscorlib.dll

Additional information: Input string was not in a correct format.

 

2./ A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in system.windows.forms.dll

Additional information: Exception has been thrown by the target of an invocation.

 

The second break is a little strange to me, because when I test the line

 

dim int as int32 = convert.toint32("a")

 

in another project then I get the same first message (after changing the exception settings), but the following message says;

 

2./ An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll

Additional information: Input string was not in a correct format.

 

and when I try to continue, the program is stopped, as expected. But in the real project, after the seconde 'first chance' message, the program keeps running... no 'unhandled exception' message comes, and the code under the problem is skipped. By the way, what is this TargetInvocation???

qrt

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...