473,327 Members | 1,979 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,327 software developers and data experts.

Problem with Drag and Drop and STAThread

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
Nov 20 '05 #1
0 2844

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

Similar topics

3
by: Jeroen Ceuppens | last post by:
Hi, When i do this in my programma, in the contstructor of the form: g.DrawImage(i,new Rectangle(0,0,i.Width,i.Height),0,0,i.Width,i.Height,GraphicsUnit.Pixel); it doens't paint it ;( but if...
2
by: SamSpade | last post by:
There seems to be two ways to put things on the clipboard ( I don't mean different formats): SetClipboardData and OleSetClipboard If I want to get data off the clipboard do I care how it was put...
3
by: Ajay Krishnan Thampi | last post by:
I have a slight problem implementing 'drag and drop' from a datagrid to a tree-view. I have pasted my code below. Someone please advice me on what to do...pretty blur right now. ==code== ...
2
by: Dante | last post by:
Has anyone ever successfully gotten a web deployed exe to have Drag Drop capabilities? I'm currently getting the message: An unhandled exception of type 'System.InvalidOperationException'...
3
by: VB Programmer | last post by:
In VB.NET 2005 (winform) any sample code to drag & drop items between 2 listboxes? Thanks!
1
by: Darren | last post by:
I'm trying to create a file using drag and drop. I want to be able to select a listview item drag it to the shell and create a file. Each icon in the listview represents a blob in a database. When...
1
by: timnels | last post by:
I have created a muti-select treeview control. Problem is I am now trying to implement drag/drop in the application that uses it. It seems the mouse down and mouse move events fire before the...
0
by: Truevision .Net | last post by:
Hi, I have a problem with drag and drop functionality when it comes to dropping pictures from sources like for example internet explorer and the webbrowser control. Dragging and dropping from...
5
by: Romulo NF | last post by:
Greetings, I´m back here to show the new version of the drag & drop table columns (original script ). I´ve found some issues with the old script, specially when trying to use 2 tables with...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.