473,325 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Unhandled exception while dragging

I do not understand why when a dragging operation is started with
DoDragDrop, no exception is handled.
The following lines illustrate what I mean. In Form2_DragDrop event, I raise
an exception at the line "int b=1/a" (so the message After Exception will
not be shown). Why this exception will be unhandled ?

using System;
using System.Windows.Forms;

public class Form2 : System.Windows.Forms.Form {
[STAThread]
static void Main() {
Application.Run(new Form2());
}

public Form2() {
this.MouseDown += new
System.Windows.Forms.MouseEventHandler(this.Form2_ MouseDown);
this.DragDrop += new
System.Windows.Forms.DragEventHandler(this.Form2_D ragDrop);
this.DragEnter += new
System.Windows.Forms.DragEventHandler(this.Form2_D ragEnter);
this.AllowDrop = true;
}

private void Form2_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e) {
DoDragDrop(this,DragDropEffects.All);
}

private void Form2_DragEnter(object sender,
System.Windows.Forms.DragEventArgs e) {
e.Effect=DragDropEffects.Copy;
}

private void Form2_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e) {
int a=0;
MessageBox.Show("Before exception");
int b=1/a;
MessageBox.Show("After exception");
}
}
Ludovic SOEUR
Nov 16 '05 #1
3 1545
Hi Ludovic,

Form2_DragDrop is called by Windows, so any unhandled exception will be
handled by Windows, so nothing appears to have happened.

If you on the other hand call Form2_DragDrop directly you will get the
Exception.

--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #2
Thanks for your answer that helped me to understand why it was not working.

But is there a way to handle this exception ? Not with a try catch in
Form2_DragDrop event with a message box but with a throw to the global
application ?

Thanks in advance.
Ludovic Soeur.

"Morten Wennevik" <Mo************@hotmail.com> a écrit dans le message de
news:opsnmv8vi6klbvpo@pbn_computer...
Hi Ludovic,

Form2_DragDrop is called by Windows, so any unhandled exception will be
handled by Windows, so nothing appears to have happened.

If you on the other hand call Form2_DragDrop directly you will get the
Exception.

--
Happy Coding!
Morten Wennevik [C# MVP]

Nov 16 '05 #3
Not to my knowledge, though I may be very wrong on this. Strictly
speaking, it is Windows that has performed an illegal action when running
part of your code, not your application.
On Mon, 14 Mar 2005 17:04:15 +0100, Ludovic SOEUR
<Lu***********@hotmail.com> wrote:
Thanks for your answer that helped me to understand why it was not
working.

But is there a way to handle this exception ? Not with a try catch in
Form2_DragDrop event with a message box but with a throw to the global
application ?

Thanks in advance.
Ludovic Soeur.

"Morten Wennevik" <Mo************@hotmail.com> a écrit dans le message de
news:opsnmv8vi6klbvpo@pbn_computer...
Hi Ludovic,

Form2_DragDrop is called by Windows, so any unhandled exception will be
handled by Windows, so nothing appears to have happened.

If you on the other hand call Form2_DragDrop directly you will get the
Exception.

--
Happy Coding!
Morten Wennevik [C# MVP]



--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #4

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

Similar topics

7
by: Chuck Hartman | last post by:
I have a Windows service that requests web pages from a site using an HttpWebRequest object. When I try to request a page from an ASP.NET 2 site, I get a WebException with message "The remote...
5
by: Dave Stewart | last post by:
I recently wrote my first Vb.net application, or at least my first complex app since moving up from vb6. When run from the VS.NET IDE, the program shows no errors and runs fine. When the output exe...
5
by: Lucvdv | last post by:
Can someone explain why this code pops up a messagebox saying the ThreadAbortException wasn't handled? The first exception is reported only in the debug pane, as expected. The second (caused by...
5
by: Samuel R. Neff | last post by:
When you have an unhandled exception in vb.net how do you view the exception information in the debugger? In C# the debugger creates a local variable that points to the exception and you can...
0
by: Colmeister | last post by:
I recently read Jason Clark's excellent article on Unhandled Exceptions (http://msdn.microsoft.com/msdnmag/issues/04/06/NET/default.aspx) and have attempted to incorporate the features he talks...
5
by: Simon Tamman {Uchiha Jax} | last post by:
Now this is bugging me. I just released software for a client and they have reported an unhandled stack overflow exception. My first concern is that the entirity of the UI and any threaded...
0
by: statlerw | last post by:
I have successfully implemented drag and drop in my application to allow the reordering of columns by dragging and dropping them in the same datagridvire (Net 2.0). If i take it relatively...
0
by: Bob | last post by:
If I induce and unhandled exception in my vb.net code for instance using '-- just a simple "object not initialized" exception (should read "as new") Dim x As Specialized.NameValueCollection ...
1
by: Bob | last post by:
In Vs 2005 you have new applicationsEvents.vb I was testing it in a simple app and found that it was easier to implement unhandled exception management tah it was in Vs2003 (vb.net) You can, if you...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.