Hi,
i have build a form with a listbox and the function that
he user can drag and drop files from the windows explorer
in this listbox. this works for me when i start it on my
localmachine.
But when i put my Apps .exe file on my WebServers WWWROOT
directory and call it from the internet explorer. the
application starts with the following error message.
----
System.InvalidOperationException: Drag & Drop-
Registrierung fehlgeschlagen --->
System.Threading.ThreadStateException: Für den aktuellen
Thread muss der STA-Modus (Single Thread Apartment)
festgelegt werden, bevor OLE-Aufrufe ausgeführt werden
können. Stellen Sie sicher, dass STAThreadAttribute für
die Hauptfunktion markiert ist.
at System.Windows.Forms.Control.SetAcceptDrops(Boolea n
accept)
----
Registering Drag & Drop failed.!?
And this is my Code:
<System.STAThreadAttribute()> _
Public Shared Sub Main()
System.Threading.Thread.CurrentThread.ApartmentSta te =
Threading.ApartmentState.STA
System.Windows.Forms.Application.Run(New Form1)
End Sub
'...
Private Sub ListBox1_DragEnter(ByVal sender As
Object, ByVal e As System.Windows.Forms.DragEventArgs)
Handles ListBox1.DragEnter
If (e.Data.GetDataPresent(DataFormats.FileDrop))
Then
e.Effect = DragDropEffects.All
Else
e.Effect = DragDropEffects.None
End If
End Sub
Private Sub ListBox1_DragDrop(ByVal sender As Object,
ByVal e As System.Windows.Forms.DragEventArgs) Handles
ListBox1.DragDrop
MsgBox("test")
Try
Dim s() As String = e.Data.GetData
("FileDrop", False)
Dim i As Integer
For i = 0 To s.Length - 1
MsgBox(s(0))
ListBox1.Items.Add(s(i))
Next i
Catch err As Exception
MsgBox(err.Message)
End Try
End Sub
i have tried it with two Treeview on the same form and
drag & drop between these treeviews. this works fine. but
when i want to drag from the windows explorer onto the
forms listbox wich is started from the internet explorer
it doesn't work!?
whats wrong???
thanks
yavuz bogazci