[Python.NET] winForms, threading and dragdrop ?
brian at zope.com
Mon Sep 12 15:18:51 CEST 2005
Hi Guy -- as far as I know, you can't change the thread
state after any COM or interop calls have happened (and
Python for .NET is all interop...).
What you probably need to do is set the attribute in
the C# 'embedding' application before initializing the
python engine (or making any other interp calls).
On Mon, 12 Sep 2005 15:38:55 +1200
Guy Robinson <guy at r-e-d.co.nz> wrote:
> From the attached code.With AllowDrop = True I get a
> .NET error as follows:
> System.InvalidOperationException: DragDrop registration
> failed. ---> System.Threading.ThreadStateException: The
> current thread must set to Single Thread Apartment (STA)
> mode before OLE calls can be made. Ensure that your Main
> function has STAThreadAttribute marked on it.
> From googling I need to set ApartmentState.STA. But this
> is readonly. How do I
> set STA correctly in Python for .NET?
> Any thoughts appeciated.
More information about the PythonDotNet