Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Drag&Drop with Powershell

Reply
 
Old 05-06-2008   #1 (permalink)
Thallid


 
 

Drag&Drop with Powershell

Hi i'm trying to implement a dragdrop-functionality in my PS-script, but i
can't get it work.

I'm not very experienced in programming so could s.o. please tell what i've
got to do?
I want to write a script with one form. It should be able to "read" the path
of a directory witch i dragdrop from WindowsExplorer to my form.

If i try to set the AllowDrop-Property i get this error: (i cant take much
out of it, maybe you can)
************** Ausnahmetext **************
System.InvalidOperationException: Fehler bei der DragDrop-Registrierung --->
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 die Hauptfunktion mit
STAThreadAttribute gekennzeichnet ist.
bei System.Windows.Forms.Control.SetAcceptDrops(Boolean accept)
--- Ende der internen Ausnahmestapelüberwachung ---


Maybe s.o. can post the code needed to achieve that.

My System SpecsSystem Spec
Old 05-06-2008   #2 (permalink)
Marco Shaw [MVP]


 
 

Re: Drag&Drop with Powershell

Thallid wrote:
Quote:

> Hi i'm trying to implement a dragdrop-functionality in my PS-script, but i
> can't get it work.
>
> I'm not very experienced in programming so could s.o. please tell what i've
> got to do?
> I want to write a script with one form. It should be able to "read" the path
> of a directory witch i dragdrop from WindowsExplorer to my form.
>
> If i try to set the AllowDrop-Property i get this error: (i cant take much
> out of it, maybe you can)
> ************** Ausnahmetext **************
> System.InvalidOperationException: Fehler bei der DragDrop-Registrierung --->
> 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 die Hauptfunktion mit
> STAThreadAttribute gekennzeichnet ist.
> bei System.Windows.Forms.Control.SetAcceptDrops(Boolean accept)
> --- Ende der internen Ausnahmestapelüberwachung ---
>
>
> Maybe s.o. can post the code needed to achieve that.
Sorry, I'm not able to read the entire error message, but do see it
refers to "STA".

Check this post for some help:
http://blogs.msdn.com/powershell/arc...on-thread.aspx

The above applies basically for PowerShell v1.

v2 is currently out as a preview release. CTP2 provides built-in
functionality for being able to run in STA mode.

"Jaykul" talks about STA here, for example:
http://huddledmasses.org/wpf-from-po...splash-screen/

Marco

--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp

PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
drag and drop .NET General
Drag and Drop General Discussion
Why I can't I Drag and Drop??? Vista mail
Access denied trying to "md"? Drag & Drop is now drag, drop, OK, OK ???? Vista installation & setup


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46