Application.ThreadException mysteriously solve a problem...

  • Thread starter Thread starter Giovanni pepe
  • Start date Start date
G

Giovanni pepe

Hello,
in a VB.NET Application I had a problem after a Drag&Drop operation from
Windows Desktop (Dataformats.filedrop) to listview....
In debug there are no errors so I've decided to implement the application
ThreadException event (throug addhandler in sub main)
After this the problem was disappeared...
Why?

Thank You
 
What was the problem? Are you using System.Windows.Forms.Clipboard together
with multiple threads?

Regards, Jakob.
 
This is my code for Drag&Drop :

Lvw_DragDrop:
--------------------------------------------------------------------------
For Each Filename In e.Data.GetData(DataFormats.FileDrop)
ReDim Preserve SourceFiles(i)
SourceFiles(i) = CompleteFilename
i = i + 1
Next
 
I tried the following code which is very similar to yours and it works fine:

Private Sub ListView1_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles ListView1.DragDrop
Dim Filename As String
For Each Filename In e.Data.GetData(DataFormats.FileDrop)
Dim item As New ListViewItem
item.Text = Filename
ListView1.Items.Add(item)

Next
End Sub

Private Sub ListView1_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles ListView1.DragEnter
If (e.Data.GetDataPresent(DataFormats.FileDrop, False)) Then
e.Effect = DragDropEffects.Copy
End If
End Sub

Are you sure that you are not using threads somewhere? Is your form running
on the main thread of your application? Are you using the MTAThreadAttribute
anywhere? Which error is generated by your code?

Regards, Jakob.
 
Back
Top