M
Mayerber
Hi,
I'm having a problem with Exceptions inside Drag&Drop
events. Here are the steps to reproduce the situation:
1) Create a new C# Windows Application;
2) Set Form1's AllowDrop property to True;
3) Type the following inside the form's DoubleClick event:
string[] a = new string[2];
a[500] = "ae";
4) Type the same inside the form's DragEnter event:
string[] a = new string[2];
a[500] = "ae";
The final code should look like:
private void Form1_DoubleClick(object sender,
System.EventArgs e)
{
string[] a = new string[2];
a[500] = "ae";
}
private void Form1_DragEnter(object sender,
System.Windows.Forms.DragEventArgs e)
{
string[] a = new string[2];
a[500] = "ae";
}
Now, run the application by pressing F5. Double-click the
Form and hopefully the "An unhandled exception of type
System.IndexOutOfRangeException..." message will be shown.
That's alright since we are accessing the 500th position
of the array and it only has 2. But now, instead of double-
clicking, drag a file onto the form. Where's the exception
message?! It is never shown!
I tried this on 3 different computers running Windows XP
SP1 (on 2 of them) and Windows 2000 Professional (on the
third) and I always get this weird behavior. Also, I
noticed this is happening inside any Drag&Drop event
(DragEnter, DragDrop, etc.)
Any comments?
All of the code was tested using MS Visual Studio .NET
2003 with .NET Framework v1.1.
Best regards,
mayerber.
I'm having a problem with Exceptions inside Drag&Drop
events. Here are the steps to reproduce the situation:
1) Create a new C# Windows Application;
2) Set Form1's AllowDrop property to True;
3) Type the following inside the form's DoubleClick event:
string[] a = new string[2];
a[500] = "ae";
4) Type the same inside the form's DragEnter event:
string[] a = new string[2];
a[500] = "ae";
The final code should look like:
private void Form1_DoubleClick(object sender,
System.EventArgs e)
{
string[] a = new string[2];
a[500] = "ae";
}
private void Form1_DragEnter(object sender,
System.Windows.Forms.DragEventArgs e)
{
string[] a = new string[2];
a[500] = "ae";
}
Now, run the application by pressing F5. Double-click the
Form and hopefully the "An unhandled exception of type
System.IndexOutOfRangeException..." message will be shown.
That's alright since we are accessing the 500th position
of the array and it only has 2. But now, instead of double-
clicking, drag a file onto the form. Where's the exception
message?! It is never shown!
I tried this on 3 different computers running Windows XP
SP1 (on 2 of them) and Windows 2000 Professional (on the
third) and I always get this weird behavior. Also, I
noticed this is happening inside any Drag&Drop event
(DragEnter, DragDrop, etc.)
Any comments?
All of the code was tested using MS Visual Studio .NET
2003 with .NET Framework v1.1.
Best regards,
mayerber.