VS2005 Exception Handling

R

RG

I understand how an exception handling occurs using try/catch when a single
statement or a block of statements are being executed. How do you handle
exceptions when you have managed code. For instance, you have databound
control and you need to catch a particular condition. How do you handle
that?

Thanks in advance
 
T

Toff McGowen

Your second and third sentences seem to contridict the first?

Try Catch Finally is a structured exception handling construct particular to
managed code. So i dont know what you mean by
How do you handle
exceptions when you have managed code. "

For instance, you have databound
control and you need to catch a particular condition.

It depends if by condition you mean event or exception? If the control
itself is throwing an undocumented exception then you have a bug on your
hands.
If it is throwing a documented exception then you wrap the method of the
control that might throw the exception in a try catch block specifically set
up to catch an exception of that type.

If by condition you meant event then you handle the event.

tm
 
R

RG

Thanks for your time and help.

I am talking about exception. Specifically, the framework was coming up
with exception when I would for instance use control incorrectly or have
datatype mismatch on databound controls. Considering that databound
controls are dropped into the application, how do you catch the exception?
as I am not writting a line of code.
In other words, I am not supplying that code. In fact, it appears that any
code that vb generates should left untouched as it would overlay the changes
on subsequent compiles.

Thanks again
 
C

CMM

In order to catch bubbled up exceptions lookup

AddHandler Application.ThreadException ...

Put that in your Sub Main... though I would wrap it in a
#IF DEBUG
conditional because during debugging it'll get in your way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top