Cheers Brian. Interestingly the script runs OK from within PythonWin. I guess PythonWin must be setting STA correctly but the python console doesn't? Guy Brian Lloyd wrote:
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@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.
Guy
-- A ReDGAS Project Robinson eDesign, P/F: +64 7 866 0626 Rings Beach, M: 021 238 0839 -ltd coverage RD2, E: guy@r-e-d.co.nz Whitianga. New Zealand The contents of this e-mail maybe CONFIDENTIAL OR LEGALLY PRIVILEGED, & is intended only for the persons named above. If this e-mail is not addressed to you, you must not use, read, distribute or copy this document. If you have received this document by mistake, please call us and destroy the original. Thank you