473,503 Members | 1,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Throwing exceptions in dragover event not catched

can someone explain :: (vs 2003)

allowdrop=true , the code is hit , but the thrown exception is never
catched ?

Why is this so?

private void button1_DragOver(object sender,
System.Windows.Forms.DragEventArgs e)
{

throw new Exception("nobody seems to catch this");

}

Johan
Nov 18 '05 #1
3 1560
Well you have a handler but did you wire up the event?

Caught.

--

Derek Davis
dd******@gmail.com

"Sagaert Johan" <RE*************@hotmail.com> wrote in message
news:er**************@TK2MSFTNGP15.phx.gbl...
can someone explain :: (vs 2003)

allowdrop=true , the code is hit , but the thrown exception is never
catched ?

Why is this so?

private void button1_DragOver(object sender,
System.Windows.Forms.DragEventArgs e)
{

throw new Exception("nobody seems to catch this");

}

Johan

Nov 19 '05 #2
YES

the ide stops there if i put a breakpoint on it.
but the exception i throw does not get caught.

Whet i put a throw inside a buttons click event, then the IDE traps the
exception and stops (as expected) when debugging.

"carion1" <dd******@gmail.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Well you have a handler but did you wire up the event?

Caught.

--

Derek Davis
dd******@gmail.com

"Sagaert Johan" <RE*************@hotmail.com> wrote in message
news:er**************@TK2MSFTNGP15.phx.gbl...
can someone explain :: (vs 2003)

allowdrop=true , the code is hit , but the thrown exception is never
catched ?

Why is this so?

private void button1_DragOver(object sender,
System.Windows.Forms.DragEventArgs e)
{

throw new Exception("nobody seems to catch this");

}

Johan


Nov 19 '05 #3
If I recall correctly...

The event may have been triggered by another thread. In the 1.1 framework,
such exceptions would be lost if you don't have an UnhandledExceptionHandler
installed. In the 2.0 framework, unhandled exceptions kill the process.

Check the stack trace to figure out exactly what code triggered the event.
In this case, I suspect it is buried deep in the OS.

In general, you should throw exceptions from event handlers. It is very hard
to determine who is triggering the event just by looking at the code, so you
have no way to determine if they are going to handle it correctly.

--
Jonathan Allen
"Sagaert Johan" <RE*************@hotmail.com> wrote in message
news:er**************@TK2MSFTNGP15.phx.gbl...
can someone explain :: (vs 2003)

allowdrop=true , the code is hit , but the thrown exception is never
catched ?

Why is this so?

private void button1_DragOver(object sender,
System.Windows.Forms.DragEventArgs e)
{

throw new Exception("nobody seems to catch this");

}

Johan

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4660
by: Mark Oueis | last post by:
I've been struggling with this question for a while. What is better design? To design functions to return error codes when an error occures, or to have them throw exceptions. If you chose the...
21
4373
by: mihai | last post by:
People say that is a bad technique to throw exception from constructors; and that the solution would be to create a function _create_ to initialize an object. What about copy constructors? How...
15
3227
by: Sek | last post by:
Gurus, I am wondering whether it is right to throw an exception from a Property of an object. To get into it further, is it okay to throw exception during 'get' operation? I was searching...
4
1221
by: Sridhar | last post by:
Hi, I would like to know the general procedure to throw exceptions. Lets say I have a datagrid in my webpage and I am pulling the data for my webpage using a function. The function accepts...
6
3540
by: Marvin Barley | last post by:
I have a class that throws exceptions in new initializer, and a static array of objects of this type. When something is wrong in initialization, CGI program crashes miserably. Debugging shows...
4
1942
by: Jay Dee | last post by:
I have a query about throwing exceptions. To throw an exception I type something like: try { // do somthing } catch (ArgumentOutOfRangeException) {
3
1935
balabaster
by: balabaster | last post by:
Hey all, this might seem somewhat remedial but I'm unable to find any documentation on it - it pertains to throwing exceptions within a DLL. I've written a DLL that contains a bunch of classes....
9
5784
by: thagor2008 | last post by:
Is the behaviour of throwing exceptions in a unix signal handler defined? eg: void sighandler(int sig) { ... do something throw myobj; }
0
1029
by: vikram rawat | last post by:
During dragover event in panel, i want to know the contol in panel on which my mouse is over? i am dragig a control in panel, but before droping the control i want to see where i have to relase...
0
7089
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7463
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5017
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3157
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1515
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.